rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

Installation fails on RubyMotion install with Ruby 1.8 #168

Closed dlo closed 12 years ago

dlo commented 12 years ago

I've just purchased RubyMotion and just ran gem install bubble-wrap. My Rakefile looks like this:

# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'bubble-wrap'

Motion::Project::App.setup do |app|
  # Use `rake config' to see complete project settings.
  app.name = 'Issues'
  app.identifier = 'io.aurora.Issues'
end

This is what happens when I run rake:

$ rake --trace
(in MYFOLDER)
rake aborted!
no such file to load -- bubble-wrap
MYFOLDER/Rakefile:4:in `require'
MYFOLDER/Rakefile:4
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2383:in `load'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2383:in `raw_load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2017:in `load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2016:in `load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2000:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:31

It appears as though the installation failed. Would love any pointers in the right direction, thanks!

clayallsopp commented 12 years ago

Looks like you're using the system-default Ruby 1.8 to run RubyMotion, that on purpose? I don't know if RubyMotion supports 1.8.x. Either way, running rake is probably using that Ruby's gem path.

What does which gem say?

supermarin commented 12 years ago

Just to confirm - are you sure you've did gem install bubble-wrap ?

dlo commented 12 years ago

@clayallsopp nope, not on purpose. I simply installed RubyMotion with the installer application. I didn't futz with the version I would be using.

@mneorr yep, just ran gem install bubble-wrap

dlo commented 12 years ago

Maybe this can be solved by running under RVM? None of the other commands fail when I do that though...

I.e., when I remove require 'bubble-wrap' from the Rakefile, rake runs perfectly and starts the app in a simulator.

clayallsopp commented 12 years ago

It seems like RubyMotion is using a version of Ruby/RubyGems that is different from what your normal gem command uses.

Check which ruby and which gem and see if they match up. Or try requiring any other non-standard gem which you know is installed and see if it also fails in the Rakefile.

But regardless, running everything under RVM/rbenv should solve that...

dlo commented 12 years ago
$ which ruby
/usr/bin/ruby
$ which gem
/usr/bin/gem

Further data:

$ ls -al /usr/bin/gem 
lrwxr-xr-x  1 root  wheel  71 Aug  6 14:12 /usr/bin/gem -> ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem
$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
$ ls -al /usr/bin/ruby
lrwxr-xr-x  1 root  wheel  76 Aug  6 14:13 /usr/bin/ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby

I'm not a ruby guy, so apologies if I'm missing something that should be obvious by now.

dlo commented 12 years ago

I don't really understand what I'm doing wrong. Is there some part of the installation that I failed to read? Pretty much my exact steps to get here were:

  1. Download RubyMotion.
  2. Install RubyMotion.
  3. Start first project.
  4. gem install bubble-wrap
  5. Requiring BubbleWrap fails.

I haven't used Ruby on this computer at any point in the past. This is a factory install.

clayallsopp commented 12 years ago

Mmm I don't think the RubyMotion installer tries to account for RubyGems, as it's not strictly required to run RubyMotion =\ You should submit a new support ticket with the motion support command and request it, though.

What I guess is happening is Ruby is looking for your gems in /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems, but the gems command isn't installing them there.

Can you paste the output of gem environment too? For comparison, mine:

$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin12.0.0]
  - INSTALLATION DIRECTORY: /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /Users/me/.rbenv/versions/1.9.3-p194/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/me/.rbenv/versions/1.9.3-p194/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/clayallsopp/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1
     - /Users/clayallsopp/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Alternatively, installing RVM/rbenv + a fresh RubyGems should fix the problem.

dlo commented 12 years ago

Yeah, it does seem this is probably a problem with the RubyMotion installation itself.

Here's my gem environment:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
  - INSTALLATION DIRECTORY: /usr/local
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-12
  - GEM PATHS:
     - /usr/local
     - /Users/dan/.gem/ruby/1.8
     - /Library/Ruby/Gems/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => false
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri --no-doc"
     - "update" => "--no-rdoc --no-ri --no-doc"
     - "gem" => "--no-rdoc --no-ri --no-doc -n/usr/local/bin"
  - REMOTE SOURCES:
     - http://rubygems.org/

You might find this useful as well:

$ ls /usr/local/gems | grep bubble-wrap
bubble-wrap-1.1.4

Per other questions:

Try ls -al /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems and seeing if a bubble-wrap directory exists.

It does not. This is very strange. I also ran the following:

$ head -n1 /usr/bin/gem
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Confirm that the output of gem list contains "bubble-wrap"

$ gem list --local | grep bubble-wrap
bubble-wrap (1.1.4)

Try running a vanilla instance of irb and executing require "bubble-wrap". If it fails, then it's a problem beyond just RubyMotion.

It fails, but I think it fails in the "good" way. :)

$ irb
irb(main):001:0> require 'bubble-wrap'
RuntimeError: This file must be required within a RubyMotion project Rakefile.
  from /usr/local/gems/bubble-wrap-1.1.4/lib/bubble-wrap/loader.rb:2
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from /usr/local/gems/bubble-wrap-1.1.4/lib/bubble-wrap/core.rb:1
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from /usr/local/gems/bubble-wrap-1.1.4/lib/bubble-wrap.rb:2
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'
  from (irb):1
dlo commented 12 years ago

Just submitted a report to the RubyMotion team.

Watson1978 commented 12 years ago

Looks like you are using Ruby18. When will use gem on Ruby18, we will require rubygems because it does not load automatically.

require 'motion/project'

require 'rubygems' # add
require 'bubble-wrap'
dlo commented 12 years ago

Thanks!