0

(Disclaimer: I am quite new to RubyGems.) I have a Sinatra app where I had a ton of require keywords so I wanted to move them into a Gemfile. So far all of them (DataMapper, Prawn, etc) work fine, until I run into this:

gem install sinatra-static-assets

and it has this error message: Permission denied - /Users/daryll/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-static-assets-1.0.4/.gitignore. I've tried bundler also but there is the same error message.

Tried forcing it via a sudo gem install (don't know if that works) and it doesn't seem to work (I am able to run the app but the I get an "undefined method stylesheet_link_tag" which means the gem isn't being seen?). What gives?

Gemfile

source 'https://rubygems.org'

gem "sinatra", "1.4.3"
gem "sinatra-static-assets", "~> 1.0.4"
gem "json", "~> 1.8.0"
gem "data_mapper", "~> 1.2.0"
gem "dm-sqlite-adapter", "~> 1.2.0"
gem "prawn", "~> 0.12.0"
gem "active_support", "~> 3.0.0"

Config.ru

require 'bundler'
Bundler.require

require './app'
run Sinatra::Application
Daryll Santos
  • 2,031
  • 3
  • 22
  • 40
  • Can you successfully run `gem install sinatra`? – David Weiser Oct 16 '13 at 22:35
  • @Davidann Yes. I tried running `bundle install` again, same error message. @AaronGray I have RVM on my machine, what exactly do you mean? (BTW I launch my app via `rackup`). – Daryll Santos Oct 16 '13 at 22:50
  • A couple things to look into: http://stackoverflow.com/questions/18320621/gem-install-rails-error-while-executing-gem-errnoeacces, http://stackoverflow.com/questions/17550903/why-do-i-get-a-permission-denied-error-while-installing-a-gem and http://stackoverflow.com/questions/5583422/rvm-gem-install-error – Aaron Gray Oct 16 '13 at 22:54
  • @AaronGray Thank you, I was able to install the gem using the third link. However I still get `undefined method stylesheet_link_tag` in my Sinatra app. Any idea why? (Maybe I will be able to debug this better when I sleep.) – Daryll Santos Oct 16 '13 at 23:05
  • When using RVM do NOT use `sudo`. Even for multi-user installations, `sudo` isn't used after the initial RVM installation. In general, trust the advice on the RVM site over ANY/ALL other sites, because they wrote it and know how it works better than anyone. I'd highly suggest you read through their entire [installation page](http://rvm.io/rvm/install), then their [troubleshooting page](http://rvm.io/support/troubleshooting) as it sound like you have trouble-brewing in your configuration. – the Tin Man Oct 16 '13 at 23:45

2 Answers2

0

I think this will solve your problem: stackoverflow.com/questions/5583422/rvm-gem-install-error

The instructions for sinatra_static_assets suggest running sudo gem install sinatra-static-assets -s http://gemcutter.org - have you tried using that?

Also, be sure to follow their instructions on the official page to be sure you have it configured properly - https://github.com/wbzyl/sinatra-static-assets/

Community
  • 1
  • 1
Aaron Gray
  • 11,283
  • 7
  • 55
  • 61
0

Two alternatives to the other answer:

1. Sandbox your gems using Bundler

I use this all the time now:

 bundle install --binstubs --path vendor

It puts all the gems in the ./vendor directory and all the executables in ./bin. Run it in the project directory e.g.

 $ cd /home/myRubyProjects/MyAmazingProject/
 $ bundle install --binstubs --path vendor

After that you can just run bundle install as the settings are kept in .bundle. No need for sudo or gemsets or worries about gems from other projects getting trampled or interacting.

2. Sinatra Exstatic Assets

I made a fork of the gem and it changed enough that it became its own library.

ian
  • 12,003
  • 9
  • 51
  • 107