NameError at / uninitialized constant Sass::SyntaxError - ruby

I am using Padrino and when I try to specify my application.sass file I get this error NameError at / uninitialized constant Sass::SyntaxError
I thought I might have something missing, so I checked out the sample_blog application at their GIT to verify my SASS is working correct. It was working correct and the blog app was running fine. Then I decided to change a line in the blog's application.sass and I got this error.
I am using TextMate to edit the file.
Weird indeed, any advices?

Yes, the issue is simple and already fixed in Padrino edge. Basically rename lib/sass.rb to lib/sass_plugin.rb. Check out the issue here: http://github.com/padrino/padrino-framework/issues/closed#issue/94

Related

Exception Load Errors, for files that exist (even in multiple places?)

I am finding these errors (via debug) and don't understand why I'm getting them. I'm not sure if I have duplicate files for a reason either. I'm using .rvm and it has a gems directory with a ruby directory inside of it, but there is also .rvm/rubies/ruby-'version' directory. I was trying to find some info about the ruby and gem folder structure but so far haven't had much luck.
In other words maybe it's possible I have multiple versions of Ruby or something isn't right?
Example rubygems.rb
Exception `LoadError' at /home/vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems.rb:1346 - cannot load such file -- rubygems
defaults/operating_system
**Yet I did a find the file**
./vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/rubygems.rb
./vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems.rb
./vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.0/lib/bundler/plugin/installer/rubygems.rb
./vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.0/lib/bundler/source/rubygems.rb
./vagrant/.rvm/gems/ruby-2.4.1/gems/bundler-1.15.1/lib/bundler/plugin/installer/rubygems.rb
./vagrant/.rvm/gems/ruby-2.4.1/gems/bundler-1.15.1/lib/bundler/source/rubygems.rb
./vagrant/.rvm/gems/ruby-2.4.1/gems/rubygems-update-2.6.12/bundler/lib/bundler/plugin/installer/rubygems.rb
./vagrant/.rvm/gems/ruby-2.4.1/gems/rubygems-update-2.6.12/bundler/lib/bundler/source/rubygems.rb
./vagrant/.rvm/gems/ruby-2.4.1/gems/rubygems-update-2.6.12/lib/rubygems.rb
vagrant#vagrant:/home$
Here is one for kernel_require.rb
Exception `LoadError' at /home/vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55 - cannot load
such file -- sinatra
Yet Sinatra was running
here are the kernel_requires
./vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb
./vagrant/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb
./vagrant/.rvm/gems/ruby-2.4.1/gems/rubygems-update-2.6.12/lib/rubygems/core_ext/kernel_require.rb
At first I thought there was another Ruby -v not being managed however I went through the RVM structure and see no discrepancies.
Anyone interested in seeing the directory structure (it wasn't on RVM site), I found it here.
It then came down to my load errors. I found a post in Ruby trunk issues that said load error, no file found for rubygems.rb was normal, if you are running debug. I believe it is looking at outside sources of rubygems?.
The last issue was syntax errors for /forwardable/impl.rb. This was because, again debug was set. Now I'm not entirely sure what the message means, but the line referenced, 6, is 'resue SyntaxError'.
So I learned a bit more using RVM , gems and some on bundler. Side note, I was able to use bundle exec on the Sinatra app.

RSpec basics: bin/rspec --format doc

I've installed RSpec on a win7 lappy and am following along the http://rspec.info/ homepage tutorial to make sure everything works. If I am reading their demo correctly bin/rspec --format doc should run the specification test file.
Instead, I get a system prompt for a text editor... ? I am confused.
Any explanation of what is going on or guidance about how to get my RSPEC configuration working in accordance to the makers homepage would be great.
FWIW Ruby 2.2.5p319, Bundler version 1.13.1 and gem -v tells me 2.6.7 (originally I had 2.4 but that is broken on windows, so I upgraded according to http://guides.rubygems.org/ssl-certificate-update/) Also, I have basic RSpec functionality and have completed the tutorial here: https://www.tutorialspoint.com/rspec/rspec_writing_specs.htm
Ah, I figured out what I need to do... I just need to explicitly call ruby:
ruby bin/rspec --format doc
...and the test gets run - YaY!
Per #JörgWMittag, I confirmed my Environment Variable Path to make sure ruby.exe was in there (C:\Ruby22\bin;).
Then looking at my Program Defaults, I thought that maybe I could tell win7 to associate any file named "rspec" with ruby.exe per https://support.microsoft.com/en-us/help/18539/windows-7-change-default-programs ...but I couldn't actually add file type "extensions" or "protocols" - I could only change the association of existing ones, but .rb and .rbw were in there... Maybe there is a way to do this manually, but I am not a windows expert.
Thinking on all this it occurred to me that I just needed to explicitly tell ruby to ingest the command... Heh.
I apologize if this is off-topic.

Sinatra - undefined method `join' for #<String> - after removing Gemfile.lock

I tried to update the Ruby version of a Sinatra website I am working on to 2.1.3. When I tried to bundle I had some errors. Then I removed the Gemfile.lock and bundle install proceeded. But when I ran the website I noticed some thing like
NoMethodError at /auth/login
undefined method `join' for #<String:0x000000062d3830>
My observations are as below.
Downgraded to Ruby 2.1.2 - problem preserved
Checked out the project as it was before (Ruby 2.1.2 with the old Gemfile.lock) worked
The error showed up with a yield_content(:head) tag.
Removed all yield_content tags
Error showed up rendering the slim file for the page - slim :index, :layout => :layout, :locals => body_locals
What could be the error? I created a diff off the state of the Gemfile.lock before and after: https://gist.github.com/ziyan-junaideen/fb903abbdafdc2d4a02f
Error output from the terminal: https://gist.github.com/ziyan-junaideen/54bff4f05a5a7beeedff
I thought it was some SLIM error and downgraded Slim to 2.0.3 which used to be before the bundle install, but had no luck.
Any suggestion is highly appreciated.
Thanks
I have solved it by reinstalling slim and temple in versions slim: 2.0.3 and temple: 0.6.8,
it's probably in temple, 'cos downgrading slim is not enough
I've got this error as well.
After some research I've found that it is happening because 'output buffer' for template rendering is an instance variable (its default name is #_out_buf), thus it is overwritten when each (sub)template rendering completes (because partials are being rendered in the same scope as main template)
There are a few ways to fix this without downgrading sinatra/slim/temple:
Make default outvar value equals to _out_buf (local variable) # lib/sinatra/base.rb#L814
Pass an outvar option to slim method like this: == slim :sub_template, outvar: '_out_buf'
I've also opened an issue at sinatra's repo at github: https://github.com/sinatra/sinatra/issues/939 (let's see what authors will say about this)

Undefined method Zip::ZipOutputStream.write_buffer on Heroku

I'm making a basic Sinatra app to play around with the Passbook gem.
My app runs fine on localhost, but when I try and run it on Heroku I get this error message:
/app/vendor/bundle/ruby/2.0.0/gems/passbook-0.2.1/lib/passbook/pkpass.rb:122:in `outputZip'
/app/vendor/bundle/ruby/2.0.0/gems/passbook-0.2.1/lib/passbook/pkpass.rb:60:in `stream'
/app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.4/lib/sinatra/base.rb:1593:in `call'
NoMethodError - undefined method `write_buffer' for Zip::ZipOutputStream:Class:
This happens when I call the line passbook.stream.string in my app file.
I don't think Passbook is the problem here - it seems that the class method write_buffer exists in the version of Zip::ZipOutputStream on my local machine but isn't there on Heroku. Why is this? How can I get around it?
I've tried including both zip and rubyzip in my Gemfile, individually and at the same time, and neither of them solve the issue.
Whenever I see something like this, I always ask myself Do you have Dev/Prod parity?.
So:
What Ruby version do you use locally, and does it differ from what you're using on Heroku?
Do you specify a Ruby version in your Gemfile?
How do you run locally? Do you use bundle exec to ensure you run in the same way, with the same gems?
Finally figured it out.
When I ran ruby app.rb, things worked locally, but when I ran bundle exec ruby app.rb, I got the same error as I did on heroku.
I upgraded to the latest version of passbook (which was just updated today to handle the latest changes to rubyzip), but things still didn't work.
Turns out I needed to remove gem 'zip' from my Gemfile and just include gem 'rubyzip' - previously I had both.

Compass mixins not found when using directly from ruby

I am building a new ruby script using GLI gem that uses Compass within. However, whenever I run the app using bundle exec SASS/Compass can never seem to find the mixins that I include in my .scss file. I get the following error...
error: File to import not found or unreadable: compass/css3.
I know the solution is to set an environment variable. However, I have no clue as to which variable needs to be set.
Update:
I should have added that this is a follow up to another post that I had - Using Compass from Ruby (not shell)
Here is the code that I am using to invoke compass from my app.
require 'compass'
require 'sass/plugin'
compiler = Compass::Compiler.new('.','.','.',{:style => :compact})
compiler.compile(sass_file,css_file)
Here is the error that is getting thrown
error: File to import not found or unreadable: compass/css3.
Load path: /Volumes/MacRAID/joeworkman/Desktop/stake-test/Badges/Badges.source/Contents
I originally thought that this only happened when I was running under bundle exec. However, its does happen every time even if I were to run in it normally.
Update #2:
I am pretty certain that this is a SASS :load_paths issue. If I set my SASS_PATH environment variable to the below value everything works. I don't want to depend on environment variables though.
~/.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/compass/stylesheets
Make sure that you check out the answers on the below post. Between my findings posted here and the suggestions made on the other post, the question is answered.
Using Compass from Ruby (not shell)

Resources