推送到Heroku时Bundler Rails 4.0应用程序错误

时间:2022-06-21 00:14:26

Before this question gets closed as duplicate let me first say that I have tried multiple solutions presented in questions of similar nature. I am working through the Ruby on Rails 4.0 Tutorial and I have gotten as far as pushing my code to Heroku. However, whenever I run the following:

在这个问题被关闭之前,我首先要说我已经尝试过在类似性质的问题中提出的多个解决方案。我正在使用Ruby on Rails 4.0 Tutorial,我已经将我的代码推送到了Heroku。但是,每当我运行以下内容时:

$ git push heroku master

I get the following:

我得到以下内容:

Counting objects: 74, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (63/63), done.
Writing objects: 100% (74/74), 15.59 KiB, done.
Total 74 (delta 11), reused 0 (delta 0)

-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 
   Running: bundle install --without development:test --path vendor/bundle --binstubs   vendor/bundle/bin --deployment
   /usr/bin/env: ruby1.9.1: No such file or directory
   Bundler Output: /usr/bin/env: ruby1.9.1: No such file or directory
   !
   !     Failed to install gems via Bundler.
   !

   !     Push rejected, failed to compile Ruby/Rails app

   To git@heroku.com:example.git
  ! [remote rejected] master -> master (pre-receive hook declined)
  error: failed to push some refs to 'git@heroku.com:example.git'

I have tried several things including changing my Gemfile (see below)

我尝试了几件事,包括更改我的Gemfile(见下文)

Gemfile :

source 'https://rubygems.org'

ruby '2.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3'
end

# Use SCSS for stylesheets
gem 'sass-rails', '4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.1.1'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails', '2.2.1'

# Turbolinks makes following links in your web application faster. Read more:     https://github.com/rails/turbolinks
gem 'turbolinks', '1.1.1'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '1.0.2'

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '0.3.20', require: false
end

group :production do
gem 'pg', '0.15.1'
end

gem 'rails_12factor', group: :production

and editing the configuration variables

并编辑配置变量

$ heroku config:set GEM_PATH = vendor/bundle/ruby/1.9.1
$ heroku config:set PATH = bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin

I have also tried running bundle from Heroku using

我也试过用Heroku运行bundle

$ heroku run "bundle update"

However I get this error

但是我收到了这个错误

bash: bundle: command not found

I have also checked my logs but those are only good for post deployment problems.

我还检查了我的日志,但这些仅适用于部署后的问题。

Does anyone know how to fix this problem?

Perhaps there is a missing file or directory on the Heroku side of things.

也许Heroku方面缺少文件或目录。

1 个解决方案

#1


3  

It appears that in order to solve this problem you need to turn off Bundler's stub generator, because Rails 4 apps do not store stubs in the app's bin/ directory. In order to do this use the following commands:

看来为了解决这个问题,你需要关闭Bundler的存根生成器,因为Rails 4应用程序不会在应用程序的bin /目录中存储存根。为此,请使用以下命令:

$ bundle config --delete bin

Then you need to update the bin directory to use the new Rails 4 executables

然后,您需要更新bin目录以使用新的Rails 4可执行文件

$ rake rails:update:bin

Then add the new bin/ directory to your version control using:

然后使用以下命令将新bin /目录添加到版本控制:

$ git add bin

Commit the changes and push your code to Heroku

提交更改并将代码推送到Heroku

#1


3  

It appears that in order to solve this problem you need to turn off Bundler's stub generator, because Rails 4 apps do not store stubs in the app's bin/ directory. In order to do this use the following commands:

看来为了解决这个问题,你需要关闭Bundler的存根生成器,因为Rails 4应用程序不会在应用程序的bin /目录中存储存根。为此,请使用以下命令:

$ bundle config --delete bin

Then you need to update the bin directory to use the new Rails 4 executables

然后,您需要更新bin目录以使用新的Rails 4可执行文件

$ rake rails:update:bin

Then add the new bin/ directory to your version control using:

然后使用以下命令将新bin /目录添加到版本控制:

$ git add bin

Commit the changes and push your code to Heroku

提交更改并将代码推送到Heroku