Project won't start on Mac OSX (noob)

As I am rather new to Ruby, and rather new to Mac OSX at the same time, I currently have a problem browsing through all the stuff on the user board.
I have searched for hints to resolve my situation, but I am afraid I cannot handle such a load of possibilities just now, since I don't understand most of it yet :-(
I am pretty involved in Resharper, C# and Visual Studio on Windows, but this is all new to me.

Just installed RubyMine 3.1 on my Mac OSX 10.6.6 (all latest updates installed).
It seems to have a ruby installed, since RubyMine detects it.  It however is not the latest version (not available to the mac ?)

I created a new application, to access my gmail account.
Installed a gem purp-ruby-gmail (adding a new rubygem repository rubygems.org) through the user interface (several times, because it sometimes did not do much, but I may well not be looking in the right places of course)
I attached to the gem (what does this mean exactly) and installed the gem (probably this means it can be found on my disk somewhere - Rubymine shows a .gem directory in my user account path that points to this gem).

So RubyMine now shows my project, with one file gmail_access.rb.  In this file I require 'gmail', which makes RubyMine not complain.  The code looks right to me and RubyMine.

require 'gmail'

class GmailAccess
  # To change this template use File | Settings | File Templates.
  def initialize
    puts "Test"
    @gmail = Gmail.new(user, password) <-- removed these strings to be able to show source code
  end

  def logout
    @gmail.logout
  end
end

a = GmailAccess.new



That's my code for now.
When I run it, it throws me an error however.

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/Me/RubymineProjects/gmail/gmail_access.rb
/Users/Me/RubymineProjects/gmail/gmail_access.rb:1:in `require': no such file to load -- gmail (LoadError)
 from /Users/Me/RubymineProjects/gmail/gmail_access.rb:1
 from -e:1:in `load'
 from -e:1

Process finished with exit code 1



My impression is that it cannot find the gem.  Should I add a path to the gem ?  Or should I add a path to the gem library ?  Or should it be listed in the OS in an environment variable ?
Or does the gem not get loaded and it should and is this a RubyMine problem ?  (I suspect not ;-)  

Too many possibilities as I cannot make a distinction between rights and wrongs just now :-(

Question 2: I have selected the MacOSX / RubyMine keyboard settings.  This gives me a Shift F10 to run (is it the file or project, I have no idea yet).  But Mac OSX does react on that key and toggles muting the machine.  What should I do to get the best RubyMine feeling, getting out of the way of Mac OSX ?  I am used to the native Resharper key bindings.

Question 3:
What I also want to do, is run the same thing on my portable, which has Windows installed.
I am thinking to throw the project on a DropBox folder, and work on it in two different locations, using RubyMine.
What should I do with the "project settings" ?  Where should I keep the gems ?  Should I duplicate them ?  I feel like both machines should have their own repositories.
But the gems I use in the project should have the exact same version, and therefore should also be put on DropBox.  Am I right in thinking this way ?

Someone please guide me in the right direction.
2 comments
Comment actions Permalink

Hi,

As I am rather new to Ruby, and rather new to Mac OSX at the same time

Ok, welcome =)

Just installed RubyMine 3.1 on my Mac OSX 10.6.6 (all latest updates installed).
It seems to have a ruby installed, since RubyMine detects it.  It however is not the latest version (not available to the mac ?)

MacOS contains bundled ruby 1.8.7 interpreter. On Mac / Linux people prefer to use Ruby Versions Manager -  RVM (http://rvm.beginrescueend.com/) which will allow you to install latest versions of Ruby including ruby 1.9.x trunk builds.

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/Me/RubymineProjects/gmail/gmail_access.rb
/Users/Me/RubymineProjects/gmail/gmail_access.rb:1:in `require': no such file to load -- gmail (LoadError)
 from /Users/Me/RubymineProjects/gmail/gmail_access.rb:1
 from -e:1:in `load'
 from -e:1

Process finished with exit code 1


My impression is that it cannot find the gem.  Should I add a path to the gem ?  Or should I add a path to the gem library ?  Or should it be listed in the OS in an environment variable ?
Or does the gem not get loaded and it should and is this a RubyMine problem ?  (I suspect not ;-)

Too many possibilities as I cannot make a distinction between rights and wrongs just now :-(

You need to "activate" gem manually or using Bundler gem.
1. Manualy

require 'rubygems' # load 'ruby-gems' library which defines 'gem' call
gem ' purp-ruby-gmail' # activates given gem. by default ruby interpreter doesn't load all gems installed in system
require 'gmail' # not it is in load path and you can require scripts bundled in gem



2. Or you can use "bunder" gem and activate gems using gem file. There are a lot of information about bundler in the Internet.

Question 2: I have selected the MacOSX / RubyMine keyboard settings.  This gives me a Shift F10 to run (is it the file or project, I have no idea yet).  But Mac OSX does react on that key and toggles muting the machine.  What should I do to get the best RubyMine feeling, getting out of the way of Mac OSX ?  I am used to the native Resharper key bindings.

Thee solutions are possible:
1. Just use MacOS oriented keymap - open "RubyMine | File | Settings | Keymap", choose "Default for Mac OS X" keymap in keymaps combobox.
2. Remap some shortcuts in RubyMine. You need open "keymap" settings pane (see 1.). Ar first copy readonly bundled keymap, that edit it as you wish.
3. Remap Mac OS default key binding.
   a. Open " | System Preferences... | Keyboard" and select "Use all F1, F2, etc. keys as standard function keys".
   b. Remap some shortcuts in " | System Preferences... | Keyboard", "Keyboard Shortcuts" tab.

A recommend you to use macos optimized RubyMine keymap (see 1.) and switch all mute/volume/.. keys From Fi (1<=i<=12) to Fn+Fi key combination, because Fi keys are more usefull for software engineering (see 3.a)

Question 3:
What I also want to do, is run the same thing on my portable, which has Windows installed.
I am thinking to throw the project on a DropBox folder, and work on it in two different locations, using RubyMine.
What should I do with the "project settings" ?  Where should I keep the gems ?  Should I duplicate them ?  I feel like both machines should have their own repositories.
But the gems I use in the project should have the exact same version, and therefore should also be put on DropBox.  Am I right in thinking this way ?

Settings are stored in ".idea" folder under your project. "workspace.xml" and "*.iml" files are OS sensitive, other files can be shared. Run configurations can be also shared using "share configuration" checkbox in run configuration settings. Shared run configurations stored as separate files in .idea/runConfigrations folder. Not shared run configrations are stored in workspace.xml file. Better is to use some Version Control System (e.g. git / svn / ...). On github (Git VCS hosting) you may create a free account for open source projects. Or you can create git or svn repo inside Dropbox folder but I'm not sure that it is a good solution.

0
Comment actions Permalink

Thx, Roman.
I have switched to the Mac OSX 10.5+ keyboard settings meanwhile.

I have been coding along on my Windows portable, and my project is up and running already.
I had removed all gem references, because the gem I was using only supported half of what I needed, so I cherry picked and went for it, with great result.

On the Mac, even this gem-less project does not run straight out of the box on RubyMine.
I got the following output:


/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/Dirk/Dropbox/dev/RubyMineProjects/gmail/program.rb
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:985:in `pick_up_tagged_response': Too many arguments provided 21if934209ebo.8 (Net::IMAP::BadResponseError)
 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:976:in `get_tagged_response'
 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:1034:in `send_command'
 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:1019:in `send_command'
 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:380:in `login'
 from ./gmail.rb:22:in `initialize'
 from ./active_gmail.rb:9:in `new'
 from ./active_gmail.rb:9:in `initialize'
 from /Users/Dirk/Dropbox/dev/RubyMineProjects/gmail/program.rb:3:in `new'
 from /Users/Dirk/Dropbox/dev/RubyMineProjects/gmail/program.rb:3
 from -e:1:in `load'
 from -e:1

Process finished with exit code 1


I gather that the Mac had installed Ruby in the location /System/Library/Frameworks/Ruby.framework.
I also did install RVM already, but could see that everything is not straight forward as on Windows :-(
I am not even sure my installation went well.  That should tell me something...
How should I check ?

Trying to install RubyMac also did something, but I couldn't tell whether this did install fine either.
How should I check ?

On Windows I can install a gem without problem (amongst others the very important ruby-debug-base gem which I can not seem to get installed on my Mac :-(
When I would like to debug, RubyMine offers me to install ruby-debug-base.
But it then fails:

       Error running gmail:
Failed to install gems. Following gems were not        installed:
linecache (0.43): Error installing linecache:
ERROR:        Failed to build gem native extension.        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby        extconf.rb mkmf.rb can't find header files for ruby at        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h        Gem files will remain installed in        /Users/Dirk/.gem/ruby/1.8/gems/linecache-0.43 for inspection. Results        logged to /Users/Dirk/.gem/ruby/1.8/gems/linecache-0.43/ext/gem_make.out        Building native extensions. This could take a while...
/Applications/RubyMine        3.1.app/rb/gems/ruby-debug-base-0.10.5.jb2.gem: Error installing        ruby-debug-base-0.10.5.jb2.gem:
ERROR: Failed to build gem native        extension.        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby        extconf.rb mkmf.rb can't find header files for ruby at        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h        Gem files will remain installed in        /Users/Dirk/.gem/ruby/1.8/gems/linecache-0.43 for inspection. Results        logged to /Users/Dirk/.gem/ruby/1.8/gems/linecache-0.43/ext/gem_make.out
And to get to that location, Mac does not make it easy for me - .gem is a hidden folder and Finder does not show it. (and I have not found a solution to this just yet :-(
I know how to get to that location with the command line however.


If the Mac provided Ruby, why does the default installation not cover these header files ?
How can I make these header files available ?  Should I reinstall Ruby ?

Getting desperate...  Should I keep using the Mac ? Windows seems 100 times easier.
Maybe with somebody's help ? Otherwise I cannot make this happen I guess...

0

Please sign in to leave a comment.