Build a Rails 6 environment with Docker.
In the terminal, I get an error when I run the following:
docker-compose exec web bash
rails new. --force --database = postgresql --skip-bundle * Error occurred here
I don't understand why the gem doesn't install properly.
Corresponding source code
run rails new. --force --database = postgresql --skip-bundle //abridgement create test/application_system_test_case.rb create storage create storage/.keep create tmp/storage create tmp/storage/.keep remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_6_0.rb rails webpacker: install Could not find gem'pg (>= 0.18,<2.0)' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.
FROM ruby: 2.6.5 RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add- RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN apt-get update RUN apt-get install -y \ build-essential \ libpq-dev \ nodejs \ postgresql-client \ yarn WORKDIR/rails6-container COPY Gemfile Gemfile.lock /rails6-container/ # 2 copy destinations are rails6-container RUN bundle install
What I tried
version: "3" volumes: db-data: services: services: web: build: .. ports: ports: -"3000: 3000" volumes: -".:/rails6-container" environment: environment: -"DATABASE_PASSWORD = postgres" tty: true stdin_open: true depends_on: --db links: links: --db db: image: postgres volumes: -"db-data:/var/lib/postgresql/data" environment: environment: -"POSTGRES_USER = postgres" -"POSTGRES_PASSWORD = postgres" -"POSTGRES_HOST_AUTH_METHOD = trust"
If i follow the steps below, it will work.
① Enter the container with docker-compose exec web bash and execute bundle install.
② rails new. --force --database = postgresql --skip-bundle
Delete the files and folders created when you executed in, and make only Dockerfile Gemfile Gemfil.lock Docker-compose.yml.
③ Run rails new. --force --database = postgresql --skip-bundle again.
You can do it this way.
However, since the work is troublesome, I would like to have bundle install installed in one shot. What kind of description should I make? ?? Thanks for your professor.
Answer # 1
Is postgresql included?
I think that it is common to put it in brew.
Since the gem called pg depends on postgresql, does it mean that the gem cannot be installed without postgresql?
- error in building environment of ruby on rails
- ruby - [rails] about the error that occurs when deleting likes (routing error)
- ruby on rails - pg :: datatypemismatch error when doing heroku run rails db: migrate
- ruby - when i try to update rails, i get a routing error
- ruby on rails 6 - [error] nomethoderror in followscontroller # destroy undefined method `destroy'for nil: nilclass
- ruby on rails - rspec test changed by -1, but was changed by 0 error
- ruby on rails - i don't understand the content of the error
- ruby on rails 6 - about rails error "wrong number of arguments (given 1, expected 0)"
- ruby on rails - i want to put what i posted on the show page, but it's a blank page it's not an error
- ruby on rails - i get an error in a program that changes over time
- ruby on rails 6 - [error] uninitialized constant user (call'userconnection' to establish a connection) :: image
- ruby on rails - nomethoderror in itemscontroller # new error
- ruby on rails - when i run rails, i get an error related to webpacker
- ruby on rails - i get an error without being created
- ruby on rails 6 - when i press new user registration, i get an error of no route matches [get] "/ users"
- ruby on rails - i get a template is missing error in render
- ruby on rails - test code causes error when product information input is successful
- ruby on rails 6 - i want to solve the error that occurred while implementing the product listing function
- ruby on rails - i want to improve rails name error
- ruby - i want to build a rails environment on docker, but i can't get an error
- ruby - unable to create table with foreign key
- ruby - [i'm having trouble with an error] cannot add foreign key constraint
- ruby - it works fine in my local environment, but when i deploy it to aws, i get an error in mysql2 :: error: unknown column
- ruby - i want to search for form information in rails and save the result
- ruby - how to pass the "password" on the wizard screen
- ruby - i want to save it in two tables when posting with form_with
- ruby binary tree problem
- ruby - rmagick cannot be installed