2013-06-28 11 views
5

से जारी होने पर Gemfile.lock नहीं बना रहा है। मेरे पास एक अजीब उपयोग-मामला है जहां मुझे रेल अनुप्रयोग पर "बंडल इंस्टॉल" (सिस्टम() कमांड के रूप में) जारी करने की आवश्यकता है एक Gemfile.lock के बिना एक और ताजा बनाया रेल आवेदन।"बंडल इंस्टॉल" एक रेल कंसोल सिस्टम कमांड

मुझे पता है कि यह आमतौर पर कमांड लाइन से किया जाता है लेकिन मुझे इसे रेल के भीतर करना होगा।

संदर्भ के बिंदु के रूप में, यह आसानी से irb के साथ प्राप्त किया जा सकता है। यह जेमफाइल के आधार पर रत्नों को अपेक्षित के रूप में लाता है और एक Gemfile.lock उत्पन्न करता है।

किसी कारण से, जब मैं रेल कंसोल (किसी अन्य ऐप से) में हूं और मैं आदेशों की एक ही श्रृंखला जारी करता हूं, तो बंडल कमांड वास्तव में रत्नों को लाता या अपडेट नहीं करता है और Gemfile.lock उत्पन्न नहीं करता है।

जैसा कि टैडमैन ने इंगित किया था, मेरा मानना ​​है कि यह irb और rails console के बीच पर्यावरण के कारण बदल रहा है। bundle install कमांड, सिस्टम() से निष्पादित होने पर, रेल ऐप पर काम कर रहा है जिसने लक्ष्य एप्लिकेशन के बजाय रेल कंसोल लॉन्च किया है।

irb में रेल कंसोल में चर से मिलान करने का प्रयास करते समय भी मैं इसे समझ नहीं सकता (नीचे दिए गए प्रयास देखें)। इस परीक्षण करने के लिए

कदम:

  1. cd && rails new myapp --skip-bundle
  2. एक और से/पूर्ण रेल एप्लिकेशन लॉन्च rails console
  3. Dir.chdir("/home/user/myapp")
  4. system("bundle install")
  5. यह वास्तव में MyApp में जवाहरात लाने नहीं है और कहीं भी होगी Gemfile.lock
नहीं बनाएं साथ

आईआरबी (सफल):

[1] pry(main)> Dir.chdir("/home/erik/facebook") 
=> 0 
[2] pry(main)> system("bundle install") 
Using rake (10.1.0) 
Using i18n (0.6.4) 
Using minitest (4.7.5) 
Using multi_json (1.7.7) 
Using atomic (1.1.10) 
Using thread_safe (0.1.0) 
Using tzinfo (0.3.37) 
Using activesupport (4.0.0.beta1) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.0.beta1) 
Using mime-types (1.23) 
Using polyglot (0.3.3) 
Using treetop (1.4.14) 
Using mail (2.5.4) 
Using actionmailer (4.0.0.beta1) 
Using activemodel (4.0.0.beta1) 
Using activerecord-deprecated_finders (0.0.3) 
Using arel (4.0.0) 
Using activerecord (4.0.0.beta1) 
Using addressable (2.3.5) 
Using annotate (2.5.0) 
Using json (1.8.0) 
Using mini_portile (0.5.0) 
Using nokogiri (1.6.0) 
Using uuidtools (2.1.4) 
Using aws-sdk (1.11.1) 
Using bcrypt-ruby (3.0.1) 
Using browser (0.1.6) 
Using xpath (2.0.0) 
Using capybara (2.1.0) 
Using ffi (1.9.0) 
Using childprocess (0.3.9) 
Using coderay (1.0.9) 
Using coffee-script-source (1.6.2) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rdoc (3.12.2) 
Using thor (0.18.1) 
Using railties (4.0.0.beta1) 
Using coffee-rails (4.0.0) 
Using diff-lcs (1.2.4) 
Using gherkin (2.12.0) 
Using cucumber (1.3.2) 
Using cucumber-rails (1.3.0) 
Using curb (0.8.4) 
Using database_cleaner (1.0.1) 
Using orm_adapter (0.4.0) 
Using warden (1.2.1) 
Using devise (2.1.3) 
Using dotenv (0.8.0) 
Using eco-source (1.1.0.rc.1) 
Using eco (1.0.0) 
Using ejs (1.0.0) 
Using launchy (2.3.0) 
Using email_spec (1.4.0) 
Using factory_girl (4.2.0) 
Using factory_girl_rails (4.2.1) 
Using foreman (0.63.0) 
Using hike (1.2.3) 
Using jquery-rails (3.0.1) 
Using kgio (2.8.0) 
Using messengerjs-rails (1.3.3) 
Using method_source (0.8.1) 
Using pg (0.15.1) 
Using protected_attributes (1.0.2) 
Using slop (3.4.5) 
Using pry (0.9.12.2) 
Using pry-rails (0.3.1) 
Using bundler (1.3.5) 
Using tilt (1.4.1) 
Using sprockets (2.10.0) 
Using sprockets-rails (2.0.0) 
Using rails (4.0.0.beta1) 
Using rails-backbone (0.7.2) 
Using rails_serve_static_assets (0.0.1) 
Using rails_stdout_logging (0.0.1) 
Using rails_12factor (0.0.2) 
Using rails_on_heroku (0.0.2) 
Using raindrops (0.11.0) 
Using rspec-core (2.13.1) 
Using rspec-expectations (2.13.0) 
Using rspec-mocks (2.13.1) 
Using rspec (2.13.0) 
Using rspec-rails (2.13.2) 
Using rubyzip (0.9.9) 
Using sass (3.2.9) 
Using sass-rails (4.0.0) 
Using websocket (1.0.7) 
Using selenium-webdriver (2.33.0) 
Using shoulda-matchers (2.2.0) 
Using simplecov-html (0.7.1) 
Using simplecov (0.7.1) 
Using uglifier (2.1.1) 
Using unicorn (4.6.3) 
Using valid_email (0.0.4) 
Your bundle is complete! 
Use `bundle show [gemname]` to see where a bundled gem is installed. 

संपादित करें: 1:

1.9.3p429 :002 > Dir.chdir("/home/user/myapp") 
=> 0 
1.9.3p429 :003 > system("bundle install") 
Updating git://github.com/plataformatec/devise.git 
Fetching gem metadata from https://rubygems.org/.......... 
Fetching gem metadata from https://rubygems.org/.. 
Resolving dependencies... 
Using rake (10.1.0) 
Using i18n (0.6.4) 
Using minitest (4.7.5) 
Using multi_json (1.7.7) 
Using atomic (1.1.10) 
Using thread_safe (0.1.0) 
Using tzinfo (0.3.37) 
Using activesupport (4.0.0.beta1) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.0.beta1) 
Using mime-types (1.23) 
Using polyglot (0.3.3) 
Using treetop (1.4.14) 
Using mail (2.5.4) 
Using actionmailer (4.0.0.beta1) 
Using activemodel (4.0.0.beta1) 
Using activerecord-deprecated_finders (0.0.3) 
Using arel (4.0.0) 
Using activerecord (4.0.0.beta1) 
Using bcrypt-ruby (3.0.1) 
Using bundler (1.3.5) 
Using coffee-script-source (1.6.2) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using json (1.8.0) 
Using rdoc (3.12.2) 
Using thor (0.18.1) 
Using railties (4.0.0.beta1) 
Using coffee-rails (4.0.0) 
Using orm_adapter (0.4.0) 
Using warden (1.2.1) 
Using devise (2.2.4) from git://github.com/plataformatec/devise.git (at rails4) 
Using google-analytics-rails (0.0.4) 
Using hike (1.2.3) 
Using jbuilder (1.0.2) 
Using jquery-rails (3.0.1) 
Using tilt (1.4.1) 
Using sprockets (2.10.0) 
Using sprockets-rails (2.0.0) 
Using rails (4.0.0.beta1) 
Using sass (3.2.9) 
Using sass-rails (4.0.0) 
Using sqlite3 (1.3.7) 
Using turbolinks (1.2.0) 
Using uglifier (2.1.1) 
Your bundle is complete! 
Use `bundle show [gemname]` to see where a bundled gem is installed. 
रेल सांत्वना (असफल) के साथ

tadman के विचार के बाद, मैं इस जो फेंकता की कोशिश की है एक अजीब बंडल त्रुटि:

[6] pry(main)> system({"BUNDLE_GEMFILE" => nil}, "bundle install") 
git://github.com/plataformatec/devise.git (at rails4) is not checked out. Please run `bundle install` 

और:

[6] pry(main)> system({"BUNDLE_GEMFILE" => "/home/user/myapp/Gemfile"}, "bundle install") 
git://github.com/plataformatec/devise.git (at rails4) is not checked out. Please run `bundle install` 

धन्यवाद! irc उपयोगकर्ता इस बात के लिए #bundler पर अप्रत्यक्ष को

Bundler.with_clean_env { Dir.chdir("/path/to/myapp") { `bundle install` } } 

सभी क्रेडिट जाता है:

+0

क्यों आप 'irb' लॉन्च कर रहे हैं और उसके बाद खोल चल खोल आदेश सीधे? – tadman

+0

@tadman चूंकि मुझे अंततः रेल ऐप से शेल कमांड जारी करने की आवश्यकता है, इसलिए मैं इसे 'irb' में परीक्षण कर रहा था और इसके बीच अंतर और रेल कंसोल को हाइलाइट कर रहा था। –

+0

मुझे लगता है कि रेल के भीतर 'Gemfile.lock' को संशोधित करना, उस फ़ाइल को पहले ही लोड कर दिया गया है, वास्तव में एक बुरा विचार की तरह लगता है। ऐसा कहा जा रहा है कि आप शायद अपने पर्यावरण में अंतर देख रहे हैं जो 'बंडलर' को भ्रमित कर रहे हैं। आप अपना आदेश 'env> env.txt' में बदल सकते हैं और दो परिणामों की तुलना कर सकते हैं। – tadman

उत्तर

6

साथ हल।

+0

यदि मैं कर सकता तो मैं आपको 100 अपवॉट्स दूंगा। –

0

मेरे मामले में Bundler.with_clean_env {Dir।chdir "/ path// MyApp के लिए" बस चलाने का आदेश बजाय {bundle install}}

टिप्पणी ही लेकिन बिना यह है कि "(" और ")"

संबंधित मुद्दे