簡體   English   中英

找不到寶石導軌

[英]Could not find gem rails

我正在嘗試構建一個 docker 容器,但收到以下錯誤消息:

Step 8/12 : RUN bundle binstubs bundler --force
 ---> Running in ed94b127974b
Could not find gem 'rails (>= 5.1.5, ~> 5.1)' in any of the gem sources listed
in your Gemfile.
ERROR: Service 'dockerzon' failed to build: The command '/bin/sh -c bundle binstubs bundler --force' returned a non-zero code: 7

我在我的 Gemfile 中嘗試了不同版本的 rails,但沒有成功! 這是我在 Gemfile 中的內容:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
# gem 'rails', '4.2.6'
# gem 'rails', '>= 5.1.5'
gem 'rails', '~> 5.1', '>= 5.1.5'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.7'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 4.1.6'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 1.0.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 3.5.1'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

gem 'pg', '~> 1.0.0'
gem 'redis-rails', '~> 5.0.2'
gem 'sidekiq', '~> 5.1.1'
gem 'puma', '~> 3.11.2'
gem 'rack-timeout', '~> 0.4.2'

這是我的 Dockerfile:

# Use the barebones version of Ruby 2.5
FROM ruby:2.5-slim

# Optionally set a maintainer name to let people know who made this image.

# Install dependencies:
# - build-essential: To ensure certain gems can be compiled
# - nodejs: Compile assets
# - libpq-dev: Communicate with postgres through the postgres gem
RUN apt-get update && apt-get install -qq -y --no-install-recommends \
      build-essential nodejs libpq-dev

# Set an environment variable to store where the app is installed to inside
# of the Docker image. The name matches the project name out of convention only.
ENV INSTALL_PATH /dockerzon
RUN mkdir -p $INSTALL_PATH

# This sets the context of where commands will be ran in and is documented
# on Docker's website extensively.
WORKDIR $INSTALL_PATH

# Ensure gems are cached and only get updated when they change. This will
# drastically increase build times when your gems do not change.
COPY Gemfile Gemfile

# We want binstubs to be available so we can directly call sidekiq and
# potentially other binaries as command overrides without depending on
# bundle exec.
# RUN bundle install --binstubs
RUN bundle binstubs bundler --force

# Copy in the application code from your work station at the current directory
# over to the working directory.
COPY . .

# Provide a dummy DATABASE_URL to Rails so it can pre-compile assets.
RUN bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname SECRET_TOKEN=dummytoken assets:precompile

# Ensure the static assets are exposed through a volume so that nginx can read
# in these values later.
VOLUME ["$INSTALL_PATH/public"]

# The default command that gets ran will be to start the Puma server.
CMD bundle exec puma -C config/puma.rb

嘗試更新 RubyGems 的版本:

gem update --system

然后將 Gemfile 中的行更改為:

gem 'rails', '~> 5.1.5'

現在運行 bundler 來安裝 gems:

bundle install

在 Dockerfile 中添加以下幾行

運行 gem 安裝導軌

ruby:2.5-slim這個 docker 鏡像不包含 rails。 它只包含紅寶石。 您不能使用 Gemfile 安裝 rails。 您必須在捆綁 gemfile 之前安裝 rails。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM