ruby-on-rails – “$bin / rails”中的“bin”是什么意思?
我正在尝试按照“入门引擎”Rails指南的教程进行操作,并发现:
$bin/rails plugin new blorgh --mountable 当我在终端上输入时,我得到: bash: bin/rails: No such file or directory 当我尝试$rails它可以正常工作. 我一直在使用命令行几个月,还有Rails.我知道$符号,但我对此之后“bin”的含义感到困惑.我习惯在$之后输入“Rails”,但本教程说使用“bin”… bin /是什么意思? 解决方法
TL;博士
运行bundle install –binstubs,它会工作.你只需要做一次,Bundler会记住你要求它(对于那个项目). 更长的答案 当您使用bundle -binstubs安装bundle时,Bundler会将所有特定于bundle的binstub安装到bin /子目录(相对于Gemfile),而不是将它们放入gemset的全局binstub路径中. 您通常会这样做: >确保您正在运行的rails binstub是Gemfile中的那个(而不是以后与Bundler分开安装到gemset中的不同版本),以及 全局binstubs与Bundler binstubs 如果你键入哪个rails,你会得到一个很长的路径,比如/usr/local/rvm/gems/jruby-1.7.18/bin/rails,其中的内容是:cat` which rails` #!/usr/bin/env jruby_executable_hooks # # This file was generated by RubyGems. # # The application 'railties' is installed as part of a gem,and # this file is here to facilitate running it. # require 'rubygems' version = ">= 0" if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding if str =~ /A_(.*)_z/ version = $1 ARGV.shift end end gem 'railties',version load Gem.bin_path('railties','rails',version) 运行bundler –binstubs之后,如果你使用bin / rails,你会得到类似的东西: #!/usr/bin/env jruby # # This file was generated by Bundler. # # The application 'rails' is installed as part of a gem,and # this file is here to facilitate running it. # require 'pathname' ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",Pathname.new(__FILE__).realpath) require 'rubygems' require 'bundler/setup' load Gem.bin_path('railties','rails') 关键的区别在于bin / version设置了BUNDLE_GEMFILE环境变量,它需要bundler / setup,这就是告诉Bundler用gem路径做的事情. bin / rails脚本具有捆绑器感知功能,并且可以识别您的Gemfile,因此它可以立即为您的环境做好准备. 我通常建议在gemset版本上使用–binstubs和bin / x调用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |