在这个问题被关闭之前,我首先要说我已经尝试过在类似性质的问题中提出的多个解决方案。我正在研究Ruby on Rails 4.0 Tutorial,我已经把我的代码推送到了Heroku。但是,每当我运行以下内容时:
$ git push heroku master
我得到以下内容:
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'
我尝试了几件事,包括更改我的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
并编辑配置变量
$ 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
我也尝试使用
从Heroku运行bundle$ heroku run "bundle update"
但是我收到此错误
bash: bundle: command not found
我还检查了我的日志,但这些仅适用于部署后的问题。
也许Heroku方面缺少文件或目录。
答案 0 :(得分:3)
似乎为了解决这个问题,你需要关闭Bundler的存根生成器,因为Rails 4应用程序不会在应用程序的bin /目录中存储存根。为此,请使用以下命令:
$ bundle config --delete bin
然后,您需要更新bin目录以使用新的Rails 4可执行文件
$ rake rails:update:bin
然后使用以下命令将新bin /目录添加到版本控制中:
$ git add bin
提交更改并将代码推送到Heroku