ruby 找不到宝石文件

wpcxdonn  于 2023-01-01  发布在  Ruby
关注(0)|答案(9)|浏览(149)

我当然不是Ruby开发人员,但我的服务器上有一个使用Ruby、Gems和Bundler的应用程序。我试图在不同的用户帐户下安装另一个Ruby,但在同一个VPS上。当我运行

bundle install

出现以下错误:
找不到宝石文件
我可以删除./bundle目录中的内容,以便重新获取所有Gems来清 debugging 误,但这是否会影响使用相同Gems和Bundler的其他应用程序?我不想冒险关闭其他应用程序。

ghhkc1vu

ghhkc1vu1#

运行该命令的目录中没有GemfileGemfile是一个包含 current 程序的gem设置的文件。

yv5phkfx

yv5phkfx2#

在运行bundle install之前,请确保您位于项目目录中。例如,在运行rails new myproject之后,您需要在运行bundle install之前运行cd myproject

cig3rfwq

cig3rfwq3#

我有同样的问题,并得到了解决,使用不同的目录。

bash-4.2$ bundle install
Could not locate Gemfile
bash-4.2$ pwd
/home/amit/redmine/redmine-2.2.2-0/apps/redmine
bash-4.2$ cd htdocs/
bash-4.2$ ls
app  config db   extra  Gemfile   lib  plugins  Rakefile     script  tmp
bin  config.ru  doc  files  Gemfile.lock  log  public   README.rdoc  test    vendor
bash-4.2$ cd plugins/
bash-4.2$ bundle install
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.3.6) 
Using activesupport (3.2.11) 
Using builder (3.0.0) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.1) 
Using actionpack (3.2.11) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.33) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using coderay (1.0.6) 
Using rack-ssl (1.3.2) 
Using json (1.7.5) 
Using rdoc (3.12) 
Using thor (0.15.4) 
Using railties (3.2.11) 
Using jquery-rails (2.0.3) 
Using mysql2 (0.3.11) 
Using net-ldap (0.3.1) 
Using ruby-openid (2.1.8) 
Using rack-openid (1.3.1) 
Using bundler (1.2.3) 
Using rails (3.2.11) 
Using rmagick (2.13.1) 
Your bundle i
km0tfn4u

km0tfn4u4#

我解决了类似的问题,只是退出项目目录,然后cd回到项目目录和捆绑安装。

cld4siwp

cld4siwp5#

很简单。当它说“找不到Gemfile”这意味着在您当前所在的文件夹或您所在的目录中,没有一个名为GemFile的文件。因此,在命令提示符中给予一个明确的或完整的路径,其中这样的文件名“Gemfile”是例如cd C:\Users\Administrator\Desktop\RubyProject\demo。
肯定一分钟就能解决。

guz6ccqo

guz6ccqo6#

你可以试试看。
将此添加到您用于运行应用的任何配置文件中。

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
Bundler.require(:default)

Rails和其他基于Rack的应用程序使用这种方案。有时候你会尝试运行一些目录比你的根目录更深的东西,你的宝石文件通常位于那里。当然你现在解决了这个问题,但偶尔我们都会遇到麻烦,这寻找宝石文件。我有时喜欢当你可以有你所有的宝石在.bundle目录也。把这个网站地址放在枕头下永远不会有坏处。http://bundler.io/

ruarlubt

ruarlubt7#

我不得不做touch Gemfile
我的案例是AWS Amazon Linux示例和Capistrano设置Puma。

qni6mghb

qni6mghb8#

在我的例子中,我尝试在脚本gem "rails", path: "../rails"中运行本地 checkout 的rails代码
ruby script.rb的身份正常运行脚本时出现错误Could not locate Gemfile or .bundle/ directory (Bundler::GemfileNotFound)
设置类似@douglasgallen的Gemfile路径解决了这个问题
BUNDLE_GEMFILE="../rails" ruby script.rb

9q78igpj

9q78igpj9#

排印错误

也许是个愚蠢的解决方案,但我有个打字错误:Gemfile而不是GemFile。希望这有帮助。

相关问题