nested_set Gemfile syntax error, unexpected ':', expecting $end - ruby-on-rails-3

in my Gemfile
gem 'nested_set', git: 'git://github.com/skyeagle/nested_set.git', tag: '~> 1.7.0' # September 11, 2013. To fix the error of wrong format of nested_st for 1.7.0
but when I run rails s, I got this error.
emfile:33: syntax error, unexpected ':', expecting $end
gem 'nested_set', git: 'git://github.com/skyeagle/ne...
^
how can I fix it? thanks!

You can fix this by using Ruby 1.9+.
The problem is that you're using the JSON-like notation which is not supported by ruby 1.8

Related

In Ruby 1.8.7, why does JSON syntax in IRB raise a Syntax, but not in a Rails 3.2.22.1 console?

I'm responsible for maintaining a legacy Ruby on Rails application, and I'm currently testing it on Ruby v1.8.7 (2013-12-22 patchlevel 375). The app is using Rails v3.2.22.1 (a Rails version provided by Rails LTS). I am bumping into a weird syntax issue.
In a vanilla IRB console, the hash rocket syntax for a Hash works as expected, and the JSON syntax for raises a syntax error as expected. However, in a Rails console, the JSON syntax is working just fine, and I can't figure out why it's NOT raising a syntax error.
Any ideas what is going on in the code below?
# in Bash
$ ruby -v
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin18.2.0]
# in Rails console
Loading development environment (Rails 3.2.22.1)
irb(main):001:0> system "ruby -v"
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin18.2.0]
=> true
irb(main):002:0> {a: 1} # JSON syntax doesn't trigger SyntaxError
=> {:a=>1}
# loading vanilla IRB *()
irb(main):003:0> system "irb" # loading vanilla IRB
# in vanilla IRB (via Rails console, if that matters)
irb(main):001:0> system "ruby -v"
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin18.2.0]
=> true
irb(main):002:0> {a: 1} # expected syntax error
SyntaxError: compile error
(irb):2: odd number list for Hash
{a: 1}
^
(irb):2: syntax error, unexpected ':', expecting '}'
{a: 1}
^
from (irb):2
It turned out that the Ruby version set in the .ruby-version was 1.9.3-p551, and that caused Rails to load using Ruby 1.9.3-p551. That wasn't immediately obvious when I got the Ruby version from the system, but checking the Ruby version from within the app revealed the difference.
$ bundle exec rails console
irb(main):001:0> system "ruby -v"
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin18.2.0]
=> true
irb(main):002:0> RUBY_VERSION
=> "1.9.3"

Gem install rails failed when used inside an rvm gemset name that includes characther colon ':'

I created an rvm gemset name that includes a colon, let's say project:marklar, then I do gem install rails inside that gemset. Everything goes well until it reaches json gem and throw this error:
Fetching: json-1.7.5.gem (100%)
Building native extensions. This could take a while...
/Users/username/.rvm/rubies/ruby-1.9.3p0/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/mysql/bin in PATH, mode 040777
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/username/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
creating Makefile
make
Makefile:158: *** target pattern contains no `%'. Stop.
I thought it was the ruby version that causes the problem, but when I changed into 1.9.2, it still throw the same error.
I used mac osx 10.8 mountain lion, surprisingly, when I removed the colon in the gemset name, let's say we changed it to marklar, everything goes well. Anyone noticed this behavior? Is this behavior expected or is it a bug in rvm, or in the json gem, or else?
I have compared Makefile defined in 1.9.3 and in 1.9.3#some:colon - there is no difference except the paths:
127,128c127,128
< RUBYLIBDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib$(target_prefix)
< RUBYARCHDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib$(target_prefix)
---
> RUBYLIBDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194#some:colon/gems/json-1.7.5/lib$(target_prefix)
> RUBYARCHDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194#some:colon/gems/json-1.7.5/lib$(target_prefix)
after further checking I found that space and colon are not allowed in file names: Escaping colons in filenames in a Makefile => http://www.mail-archive.com/bug-make#gnu.org/msg03318.html

Could not find generator mini_test:install

I expected these generators to be available:
$ rails g
Usage: rails generate GENERATOR [args] [options]
MiniTest:
mini_test:controller
mini_test:helper
mini_test:install
mini_test:mailer
mini_test:model
mini_test:scaffold
So I ran:
$ rails g mini_test:install
But got this error:
Could not find generator mini_test:install.
As for my environment, here is the relevant portion of my Gemfile:
group :test, :development do
gem 'minitest-rails'
end
And the resulting portions of my Gemfile.lock:
minitest (2.12.1)
minitest-rails (0.0.7)
minitest (~> 2.12)
rails (~> 3.1)
I am now in the process of debugging this. I would appreciate any tips. In any case, I will report back.
This is fixed in the 0.1 release of minitest-rails.
https://github.com/blowmage/minitest-rails
According to minitest-rails issue #41 - Generators are not found:
Try the prerelease gem, 0.1.0.alpha. Its a different approach and you'll need to update any existing tests.
I just confirmed that this worked for me:
$ rails g mini_test:install
create test
create test/minitest_helper.rb

ActiveRecord Causing SQLException in Rspec Test

UPDATE: My issue is definitely related to this one - it's an issue with ActiveRecord. Still not solved.
I'm trying to get a test to pass in rspec and can't figure out what's going wrong... Here's what I'm getting:
Running: spec/models/user_spec.rb
.
.
.
........F
Failures:
1) User when email address is already taken
Failure/Error: user_with_same_email.save
ActiveRecord::StatementInvalid:
SQLite3::SQLException: near "SAVEPOINT":
syntax error: SAVEPOINT active_record_1
# ./spec/models/user_spec.rb:64:in `block (3 levels) in <top (required)>'
Finished in 0.22908 seconds
9 examples, 1 failure
Here's the related line in my test:
user_with_same_email.save
it breaks when trying to write to the db. Development is fine - no issues.
Thanks
The issue was an old version of sqlite. I installed Homebrew and ran brew install sqlite3
A number of errors came up due to files that already existed. I just renamed them *.old and ran brew link sqlite3. Problem solved!

Heroku paypal_adaptive gem setup

I have paypal_adaptive gem on my local development machine working. But when deployed heroku throws me error that:
ArgumentError: syntax error on line 20, col 2: ` ssl_cert_file:'
/usr/ruby1.9.2/lib/ruby/1.9.1/syck.rb:135:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/syck.rb:135:in `load'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/paypal_adaptive-a3853ca1635b/lib/paypal_adaptive/config.rb:32:in `load
I tried with and without line "ssl_cert_file:" in YML file and variables are saved to ENV variables to Heroku. I suspect that gem can't find YML file. How to force gem to find that YML file.
I sent a fix related to this that has been pulled in. http.rb can't handle non strings
See: https://github.com/tc/paypal_adaptive/commit/3e94637d56959994dc4c57186209f071fecc46bb
The gem just needs a version bump.