【发布时间】:2023-03-06 07:21:01
【问题描述】:
我得到了一个使用 Ruby on Rails 构建的网站。我认为该网站是大约 3 年前建立的。我正在尝试在本地计算机上启动并运行它,但在尝试运行服务器时出现了一些错误。
版本:Ruby 2.4.0p0
Rails 5.1.1
自制 1.2.3
Git 版本 2.11.0
当我运行 rails s 时,我收到此错误:
Could not find proper version of railties (3.2.6) in any of the sources
Run `bundle install` to install missing gems.
当我运行bundle install 时,我得到:
An error occurred while installing json (1.8.0), and Bundler cannot
continue.
Make sure that `gem install json -v '1.8.0'` succeeds before bundling.
我用谷歌搜索了错误并尝试了各种方法,但仍然没有运气。 有人说要在 gem 文件中添加 gem 'json', '1.8.0' 但还是不行
这是gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '> 0.3'
gem 'bluecloth'
gem 'simple_form'
gem 'carrierwave'
gem 'rmagick'
gem 'capistrano'
gem 'rvm-capistrano'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
这是因为版本不兼容吗?
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.6)
actionpack (= 3.2.6)
mail (~> 2.4.4)
actionpack (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
activerecord (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
bluecloth (2.2.0)
builder (3.0.0)
capistrano (2.12.0)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
carrierwave (0.6.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
highline (1.6.12)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.3)
libv8 (3.16.14.13)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
mysql2 (0.3.11)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.5.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.6)
actionmailer (= 3.2.6)
actionpack (= 3.2.6)
activerecord (= 3.2.6)
activeresource (= 3.2.6)
activesupport (= 3.2.6)
bundler (~> 1.0)
railties (= 3.2.6)
railties (3.2.6)
actionpack (= 3.2.6)
activesupport (= 3.2.6)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
ref (2.0.0)
rmagick (2.13.1)
rvm-capistrano (1.4.1)
capistrano (>= 2.0.0)
sass (3.1.20)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
simple_form (2.0.1)
actionpack (~> 3.0)
activemodel (~> 3.0)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.15.4)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.6)
execjs (>= 0.3.0)
multi_json (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
bluecloth
capistrano
carrierwave
coffee-rails (~> 3.2.1)
jquery-rails
mysql2 (> 0.3)
rails (= 3.2.6)
rmagick
rvm-capistrano
sass-rails (~> 3.2.3)
simple_form
therubyracer
uglifier (>= 1.0.3)
当我运行 gem install json -v '1.8.0' 时,我得到了以下信息(对于与我有同样问题但没有奏效的人,这也得到了很多建议——即使使用 sudo 也是如此):
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0/ext/json/ext/generator
/Users/me/.rvm/rubies/ruby-2.4.0/bin/ruby -r ./siteconf20170622-61950-1tcycqj.rb extconf.rb
creating Makefile
current directory: /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:47: error: too few arguments provided to function-like macro invocation
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
/Users/me/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0/ruby/intern.h:795:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
^
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'VALUE (const char *, long)' (aka 'unsigned long (const char *, long)') [-Wint-conversion]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^ ~~~~~~~~~~
generator.c:840:25: error: use of undeclared identifier 'rb_cFixnum'
} else if (klass == rb_cFixnum) {
^
generator.c:842:25: error: use of undeclared identifier 'rb_cBignum'
} else if (klass == rb_cBignum) {
^
1 warning and 3 errors generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-2.4.0/extensions/x86_64-darwin-16/2.4.0/json-1.8.0/gem_make.out
【问题讨论】:
-
当您尝试
gem install json -v '1.8.0'时会发生什么?您可能需要使用sudo运行它。 -
gem install json -v '1.8.0': 返回一个错误,和我用 sudo 运行它一样
-
您的
Gemfile.lock是什么样的?这将向您展示您现有的 gem 的依赖关系,这可能会阐明问题。 -
@idm 和你最初遇到的错误一样吗?
-
@octopushugs 我已将 Gemfile.lock 代码添加到我的问题中。谢谢
标签: ruby-on-rails