1
`require': LoadError: cannot load such file -- mysql2/mysql2 (Sequel::AdapterNotFound)「捆綁安裝」工作時,爲什麼「捆綁安裝 - 路徑」中斷?
只有當我使用bundle install --path
時,我纔會收到上述錯誤。當我切換到正常bundle install
一切都完美的作品。
在我的頭靠在牆上打了太多時間之後,我認爲是時候尋求幫助了。我如何獲得bundle install --path
的工作?我認爲它與碼頭集裝箱內的捆綁環境有關?
這個捆綁ENV工作:
Environment
Bundler 1.13.6
Rubygems 2.6.8
Ruby 2.3.2p217 (2016-11-15 revision 56796) [x86_64-linux]
GEM_HOME /usr/local/bundle
GEM_PATH
Git 2.1.4
Bundler settings
disable_shared_gems
Set for your local app (/usr/local/bundle/config): "true"
path
Set via BUNDLE_PATH: "/usr/local/bundle"
bin
Set via BUNDLE_BIN: "/usr/local/bundle/bin"
silence_root_warning
Set via BUNDLE_SILENCE_ROOT_WARNING: "1"
app_config
Set via BUNDLE_APP_CONFIG: "/usr/local/bundle"
bin_path
Set via BUNDLE_BIN_PATH: "/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle"
gemfile
Set via BUNDLE_GEMFILE: "/usr/src/app/Gemfile"
這束ENV不起作用:
Environment
Bundler 1.13.6
Rubygems 2.6.8
Ruby 2.3.2p217 (2016-11-15 revision 56796) [x86_64-linux]
GEM_HOME /usr/src/app/vendor/bundle/ruby/2.3.0
GEM_PATH
Git 2.1.4
Bundler settings
path
Set for your local app (/usr/local/bundle/config): "vendor/bundle"
Set via BUNDLE_PATH: "/usr/local/bundle"
disable_shared_gems
Set for your local app (/usr/local/bundle/config): "true"
bin
Set via BUNDLE_BIN: "/usr/local/bundle/bin"
silence_root_warning
Set via BUNDLE_SILENCE_ROOT_WARNING: "1"
app_config
Set via BUNDLE_APP_CONFIG: "/usr/local/bundle"
bin_path
Set via BUNDLE_BIN_PATH: "/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle"
gemfile
Set via BUNDLE_GEMFILE: "/usr/src/app/Gemfile"
Dockerfile:
FROM ruby:2.3.2
WORKDIR /usr/src/app
COPY Gemfile .
RUN bundle install --path vendor/bundle
泊塢窗,compose.yml:
version: "2"
services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/usr/src/app
links:
- db
db:
image: mysql:5.6
ports:
- "3306:3306"
volumes:
- ./schema/create_markup.sql:/docker-entrypoint-initdb.d/create_markup.sql
- db_data:/var/lib/mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
db_data:
的Gemfile:
volumes:
- .:/usr/src/app
的寶石:
# frozen_string_literal: true
source "https://rubygems.org"
gem "mysql2"
gem "sequel"
group :test do
gem "rspec"
end
我的應用程序位於'/ usr/src/app'目錄下,但是要將gem安裝到'/ usr/src/app/vendor/bundle'目錄下。在這種情況下,我要裝載什麼。有'COPY。 Dockerfile中的/ usr/src/app'不起作用 – binarymason
在我看來,如果爲每個應用程序構建一個映像,則不需要設置bundle路徑。但是如果你想把gem安裝到'/ usr/src/app/vendor/bundle'中,你可以在安裝之後綁定安裝並將gem保存在主機上。 – minamijoyo