Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails:如何正确使用捆绑安装选项_Ruby On Rails_Ruby_Rubygems_Bundler_Config - Fatal编程技术网

Ruby on rails Rails:如何正确使用捆绑安装选项

Ruby on rails Rails:如何正确使用捆绑安装选项,ruby-on-rails,ruby,rubygems,bundler,config,Ruby On Rails,Ruby,Rubygems,Bundler,Config,我刚刚尝试在运行rails 3.2.5(ruby 1.8.7)的服务器上使用mysql后端创建一个新的rails应用程序: rails new myapp -d mysql 到目前为止一切进展顺利。但是,如果我尝试使用rakedb:create创建数据库,我会得到以下结果: Could not find gem 'therubyracer (~> 0.12.0) ruby' in the gems available on this machine. Run `bundle instal

我刚刚尝试在运行rails 3.2.5(ruby 1.8.7)的服务器上使用mysql后端创建一个新的rails应用程序:

rails new myapp -d mysql
到目前为止一切进展顺利。但是,如果我尝试使用
rakedb:create
创建数据库,我会得到以下结果:

Could not find gem 'therubyracer (~> 0.12.0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
如果按照建议执行(运行
bundle install
),我会得到一个将要使用(并且似乎已经安装)的gem列表,此时会出现另一个错误:

...
Using ref (1.0.5) 
Using sass (3.2.13) 
Using sass-rails (3.2.6) 
Installing therubyracer (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby18 extconf.rb 
checking for main() in -lpthread... yes
checking for v8.h... no
*** extconf.rb failed ***
所以对我来说,这表明rake在错误的位置寻找v8。错误公告还建议如何使用配置选项解决此问题:

You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby18
--with-pthreadlib
--without-pthreadlib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError) and *not* the one that is bundle with the libv8 rubygem. However, it could not be located. please make sure you have a version of v8 that is compatible with 3.16.14.3 installed. You may need to special --with-v8-dir options if it is in a non-standard location
看起来我必须像
bundle config一样配置
bundle
过程--一些选项
,但是哪个选项可以做到这一点呢?我已经尝试了所有与v8相关的选项,但都不起作用。以
--with-v8-xxx
开头的选项似乎不允许设置本地安装的v8库的路径(
gem list
提供了使用libv8(3.16.14.3)的
,我可以在本地
.gem
目录中看到该文件夹)。
--without-v8-xxx
也不可用,因为我不知道系统范围的v8库的位置(没有搜索服务器的权限)

我怎样才能解决我的问题

谢谢


好的,看来我可以继续了。调用安装,比如
rubygems-gem-install-libv8
,似乎说服了extconf.rb在本地gems中而不是在系统位置中查找v8.h。但是,我还没有到那里:

ERROR:  Error installing therubyracer:
ERROR: Failed to build gem native extension.

    /usr/bin/ruby18 extconf.rb
checking for main() in -lpthread... yes
*** extconf.rb failed ***
。。。后来:

/kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `initialize': No such file or directory - /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/.location.yml (Errno::ENOENT)
from /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `open'
from /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `load!'
from /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/lib/libv8.rb:6:in `configure_makefile'
from extconf.rb:32
错误帖子也为我提供了一些我可以使用的选项,但我根本不明白是什么导致了错误

有什么想法吗


谢谢

您可以使用
bundle config
将配置标志传递给您的gems,如下所示

bundle config build.libv8 --without-v8-lib=/path/to/lib
bundle config build.libv8 --without-system-v8
通过运行
bundle help config

更新:根据您收到的错误消息判断,似乎libv8 gem是在查找系统的v8时生成的(不确定这是默认设置的原因)。幸运的是,gem与v8源代码捆绑在一起,但是您需要明确地告诉它使用它,如下所示

bundle config build.libv8 --without-v8-lib=/path/to/lib
bundle config build.libv8 --without-system-v8
您可以使用以下选项:

gem install libv8 -v 3.11.8.17 -- --with-system-v8

啊,谢谢。现在我看到我的home目录中有一个.bundle目录,其中包含我刚才设置的配置。然而,事情仍然不起作用-我不知道没有路径(不幸的是)。简单地将--without-v8-lib更改为--with-v8-lib并提供本地安装的gem的路径是行不通的(我认为--with-v8-lib不采用任何路径…),我很抱歉地说-bundle-config build.libv8--without-system-v8也没有做到这一点。bundle install仍在错误的位置查找v8.h:Gem::Installer::ExtensionBuildError:错误:未能生成Gem本机扩展/usr/bin/ruby18 extconf.rb正在检查-lpthread中的main()。。。是,正在检查v8.h。。。否***extconf.rb失败***您确定这不是因为您之前设置的标志(--with-v8-lib)和system-v8标志之间存在冲突吗?我想是的。。。据我所知,所有设置--without-system-v8选项所做的是将~/.bundle/config重写为bundle\u BUILD\u LIBV8:--without-system-v8恐怕我没有更多的帮助,对不起。