ruby-on-rails – Docker&Rails | bundler:找不到命令:rails

ruby-on-rails – Docker&Rails | bundler:找不到命令:rails,第1张

概述我是Docker的新手,对Rails来说还是新手. 当我运行docker-compose时,我收到此错误: web_1 | bundler: command not found: railsweb_1 | Install missing gem executables with `bundle install`app_web_1 exited with code 127 最初我在运行bun 我是Docker的新手,对Rails来说还是新手.

当我运行docker-compose时,我收到此错误:

web_1  | bundler: command not found: railsweb_1  | Install missing gem executables with `bundle install`app_web_1 exited with code 127

最初我在运行bundle install时遇到任何gem都遇到了麻烦.我的Gemfile中的每一个Gem都出现了“找不到任何来源的宝石”的错误.然后我尝试运行bundle(没有安装),它没有返回任何错误.

Rails肯定是安装的,因为输入rails给了我所有的使用选项.

此外,我可以看到供应商/缓存中的宝石.我尝试删除所有这些并运行bundle install,当捆绑器安装它们时,它们都开始逐个出现.

编辑:请随意纠正我的理解:因为运行bundle install意味着在Docker实例上安装gem,它不是“本地”安装的.在尝试解决此问题时,我在本地删除了所有宝石并重新安装了bundler.所以,当我运行gems List时,我只看到bundler.我运行了bundler install,它声称正在安装所有的gem.他们在哪里安装?它说这是供应商/缓存,这是真的.我可以在那里看到它们,但它仍然找不到任何宝石:它甚至找不到铁轨.

编辑2:我还应该提一下:bin / rails s启动服务器就好了.由于数据库实例没有运行,它不会加载任何东西,但我认为这是有道理的.

编辑3:我在本地运行gem install rails,仍然没有变化,但现在gems List返回rails及其依赖项.

下面是一些下面可能相关的文件和日志,可以帮助确定原因.请注意我将实际的应用程序名称更改为app.

运行gems列表返回:

*** LOCAL GEMS ***actionmailer (5.1.1)actionpack (5.1.1)actionvIEw (5.1.1)activejob (5.1.1)activemodel (5.1.1)activerecord (5.1.1)activesupport (5.1.1)arel (8.0.0)builder (3.2.3)bundler (1.15.0)concurrent-ruby (1.0.5)erubi (1.6.0)globalID (0.4.0)i18n (0.8.1)loofah (2.0.3)mail (2.6.5)method_source (0.8.2)mime-types (3.1)mime-types-data (3.2016.0521)mini_portile2 (2.1.0)minitest (5.10.2)nio4r (2.0.0)nokogiri (1.7.2)rack (2.0.3)rack-test (0.6.3)rails (5.1.1)rails-dom-testing (2.0.3)rails-HTML-sanitizer (1.0.3)railtIEs (5.1.1)rake (12.0.0)sprockets (3.7.1)sprockets-rails (3.2.0)thor (0.19.4)thread_safe (0.3.6)tzinfo (1.2.3)websocket-driver (0.6.5)websocket-extensions (0.1.2)

我的Gemfile看起来像这样:

source 'https://rubygems.org'git_source(:github) do |repo_name|  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")  "https://github.com/#{repo_name}.git"endgem 'gmail'gem 'oauth','0.5.2'gem 'twilio'# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'gem 'rails','~> 5.0.1'# Use postgres as the database for Active Recordgem 'pg'# Use Puma as the app servergem 'puma','~> 3.0'# Use SCSS for stylesheetsgem 'sass-rails','~> 5.0'# Use UglifIEr as compressor for JavaScript assetsgem 'uglifIEr','>= 1.3.0'# Use CoffeeScript for .coffee assets and vIEwsgem 'coffee-rails','~> 4.2'# See https://github.com/rails/execJs#readme for more supported runtimes# gem 'therubyracer',platforms: :ruby# Use jquery as the JavaScript librarygem 'jquery-rails'# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinksgem 'turbolinks','~> 5'# Build JsON APIs with ease. Read more: https://github.com/rails/jbuildergem 'jbuilder','~> 2.5'# Use Redis adapter to run Action Cable in production# gem 'redis','~> 3.0'# Use ActiveModel has_secure_password# gem 'bcrypt','~> 3.1.7'# Use CAPIstrano for deployment# gem 'cAPIstrano-rails',group: :developmentgroup :development,:test do  # Call 'byeBUG' anywhere in the code to stop execution and get a deBUGger console  gem 'byeBUG',platform: :mriendgroup :development do  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.  gem 'web-console','>= 3.3.0'  gem 'Listen','~> 3.0.5'  # Spring speeds up development by keePing your application running in the background. Read more: https://github.com/rails/spring  gem 'spring'  gem 'spring-watcher-Listen','~> 2.0.0'end# windows does not include zoneinfo files,so bundle the tzinfo-data gemgem 'tzinfo-data',platforms: [:mingw,:mswin,:x64_mingw,:jruby]

我的docker-compose.yml文件如下所示:

version: '2'services:  db:    image: postgres    volumes:      - ./postgres-data:/var/lib/postgresql/data  web:    build: .    command: bundle exec rails s -p 3000 -b '0.0.0.0'    volumes:      - .:/app    ports:      - "3000:3000"    depends_on:      - db

我的Dockerfile看起来像这样:

FROM ruby:2.4.0RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodeJsRUN mkdir /appworkdir /appADD Gemfile /app/GemfileADD Gemfile.lock /app/Gemfile.lockADD . /app

运行bundle install会返回:

Using rake 12.0.0Using oauth 0.5.2Using mime-types-data 3.2016.0521Using builder 3.2.3Using multi_xml 0.6.0Using concurrent-ruby 1.0.5Using i18n 0.8.1Using minitest 5.10.2Using thread_safe 0.3.6Using erubis 2.7.0Using mini_portile2 2.1.0Using rack 2.0.3Using nio4r 2.0.0Using websocket-extensions 0.1.2Using arel 7.1.4Using method_source 0.8.2Using thor 0.19.4Using bundler 1.15.0Using pg 0.20.0Using puma 3.8.2Using sass 3.4.24Using tilt 2.0.7Using execJs 2.7.0Using coffee-script-source 1.12.2Using turbolinks-source 5.0.3Using multi_Json 1.12.1Using byeBUG 9.0.6Using bindex 0.5.0Using rb-fsevent 0.9.8Using ffi 1.9.18Using gmail_xoauth 0.4.2Using mime-types 3.1Using httparty 0.15.5Using tzinfo 1.2.3Using nokogiri 1.7.2Using rack-test 0.6.3Using sprockets 3.7.1Using websocket-driver 0.6.5Using uglifIEr 3.2.0Using coffee-script 2.4.1Using turbolinks 5.0.1Using rb-inotify 0.9.8Using mail 2.6.5Using twilio 3.1.1Using activesupport 5.0.3Using loofah 2.0.3Using Listen 3.0.8Using gmail 0.6.0Using rails-dom-testing 2.0.3Using globalID 0.4.0Using activemodel 5.0.3Using jbuilder 2.6.4Using spring 2.0.1Using rails-HTML-sanitizer 1.0.3Using activejob 5.0.3Using activerecord 5.0.3Using spring-watcher-Listen 2.0.1Using actionvIEw 5.0.3Using actionpack 5.0.3Using actioncable 5.0.3Using actionmailer 5.0.3Using railtIEs 5.0.3Using sprockets-rails 3.2.0Using coffee-rails 4.2.1Using jquery-rails 4.3.1Using web-console 3.5.1Using rails 5.0.3Using sass-rails 5.0.6Updating files in vendor/cacheBundle complete! 18 Gemfile dependencIEs,68 gems Now installed.Bundled gems are installed into ./vendor/cache.
解决方法 我不确定这是否是一个合适的解决方案,但我尝试添加

RUN bundler install

到我的Dockerfile.我删除了所有的图像,运行了docker-compose up并像魅力一样工作.

总结

以上是内存溢出为你收集整理的ruby-on-rails – Docker&Rails | bundler:找不到命令:rails全部内容,希望文章能够帮你解决ruby-on-rails – Docker&Rails | bundler:找不到命令:rails所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1292453.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-10
下一篇 2022-06-10

发表评论

登录后才能评论

评论列表(0条)

保存