0

I'm learning Rails and fairly new to Macports.

I receive the following error when running rails server for my project:

/...config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end

I believe this syntax error is caused by running a version of Rails less than 1.9.0 confirmed because ruby -v gives me ruby 1.8.7.

The problem is that I'm sure I have installed ruby 1.9.3

I've run port clean ruby19 and various combinations to install ruby 1.9.3

port install ruby19

port install ruby19 -nosuffix

Both give me the following error:

Error: org.macports.activate for port ruby19 returned: Image error: /opt/local/bin/erb is being used by the active ruby port. Please deactivate this port first, or use 'port -f activate ruby19' to force the activation.

If I run port -f activate ruby19 I get this error:

--->  The following versions of ruby19 are currently installed:
--->      ruby19 @1.9.3-p194_3+doc (active)
--->      ruby19 @1.9.3-p194_3+doc+mactk
--->      ruby19 @1.9.3-p194_3+doc+nosuffix
Error: port activate failed: Registry error: Please specify the full version as recorded in the port registry.

Where do I go from here?!

I basically want the quickest simplest solution to get this project up and running - I don't need multiple versions of ruby on my machine.

Come on I know I can't be the first with this problem! Is RVM really the only way people do this?

Many thanks in advance!

benedict_w
  • 3,543
  • 1
  • 32
  • 49

2 Answers2

2

Go with rvm which is a lot less of a hassle, works locally and is updated more frequently. You could also use rbenv or any of the other ruby installers that are out there. Save yourself some time and go with these installers.

three
  • 8,262
  • 3
  • 35
  • 39
  • Thanks - I'll take a look. What is RVM is it an alternative to macports? – benedict_w Sep 16 '12 at 19:28
  • rvm is a local ruby installer that lets you run several rubies in parallel, i.e. you chose which one you want to run right now in terminal and lets you change that with a simple command. – three Sep 16 '12 at 19:44
  • I see - ideally I'd like to get it up and running with macports as that is how I have everything else on my machine at the moment. I don't yet need multiple versions of Ruby. If I truly can't get a macports version working I'll investigate RVM further. Thanks! – benedict_w Sep 16 '12 at 19:58
  • sure, that's fine. I thought you picked Macports only as a means to install Ruby. It's good for what it does! – three Sep 17 '12 at 11:43
0

It turns out I already had a macports install of ruby (1.8.7).

I uninstalled all my macports ruby19 editions sudo port uninstall ...

deactivated the active version sudo port -f deactivate ruby

and installed the version of 1.9.3 with no suffix

sudo port install ruby19 +nosuffix

I received this error:

Image error: /opt/local/bin/gem is being used by the active rb-rubygems port. Please deactivate this port first, or use 'port -f activate ruby19' to force the activation.

so ran sudo port -f activate ruby19

now when I run rails server I get:

/opt/local/lib/ruby1.9/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /opt/local/lib/ruby1.9/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /opt/local/lib/ruby1.9/1.9.1/rubygems.rb:1231:in `gem'
from /opt/local/bin/rails:22:in `<main>'

I then updated my gem package and rails:

sudo gem update --system
sudo gem uninstall rubygems-update
sudo gem install rails
sudo bundle install

result:

Your bundle is complete! Use 'bundle show [gemname]' to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
  = 1.8.7 : gem install rdoc-data; rdoc-data --install
  = 1.9.1 : gem install rdoc-data; rdoc-data --install
 >= 1.9.2 : nothing to do! Yay!

A useful discussion here on macports and ruby paths: How does MacPorts install packages? How can I activate a Ruby installation done via MacPorts?

Many people recommend RVM https://rvm.io/, but for me I just need 1.9.2 running for now.

Community
  • 1
  • 1
benedict_w
  • 3,543
  • 1
  • 32
  • 49