I'm trying to install rails but I get a "marshal data too short" error. I read in this question ( bundle update fails : marshal data too short ) that I can update the Gemfile to make it work.
My problem is that I really have no idea how to modify this "Gemfile".
Thx.
Damn, it was so simple... to update the gemfile, you only got to execute these two command lines:
gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
Then you can execute your installation normally:
gem install rails
Go to the root of your application, and look for Gemfile. The root of the application is where you run rails server from, in case you were wondering :)
Open Gemfile using your favorite text editor, and try changing the rubygems source from HTTP to HTTPS.
Locate the following:
source 'http://rubygems.org'
Replace it with:
source 'https://rubygems.org'
You might want to check out this thread: Marshal data too short
Related
I need to make changed to the Twitter gem, so I cloned it to a local folder, then changed my bundle file like so:
gem 'twitter', :path => '~/code/twitter-ruby'
I added a new method, and ran a test that simply calls the method, to start off with. But I get an error of undefined method. In other words, it hasn't detected my changes. I tried commenting out a whole file, ran my other tests and those all worked, as though the file were still there.
In my project I'm still importing as require 'twitter'.
I've tried running bundle update twitter, I've tried removing it from the bundle, I've tried increasing the version number (which it does detect, and updates to the most recent version), I've tried committing my changes to GIT. Nothing seems to work - I just keep getting the same undefined method error. Any ideas?
EDIT: my Gemfile.lock:
PATH
remote: /Users/Andrew/code/twitter
specs:
twitter (5.15.0)
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
ruby
DEPENDENCIES
twitter!
BUNDLED WITH
1.12.4
My issue was that I was using bundle to install the gems, but I wasn't using bundle exec to run my application. It became clear after running the uninstall suggestion and the require my_lib line starting to fail inside irb. bundle exec irb allowed it to work using the gem path defined in the Gemfile.
try this out:
First uninstall the twitter gem, by doing gem uninstall twitter, then do bundle install
Try giving the branch name too.
gem 'twitter', path: <absolute-path-to-your-local-twitter-repo>, branch: <branch-name>
EDIT
e.g. path as "/Users/me/path/to/repo"
And run
bundle update twitter
Then restart server, if running as a web application.
I am trying to push into rubygems.orge a simple gem following this tutorial. Basically I am using bundler and I have write a simple Hello World class. Then, I try to push the gem as follows:
bundle gem my_first_gem
gem build my_first_gem-0.0.1.gem
and I get:
Signed in.
Pushing gem to https://rubygems.org...
Repushing of gem versions is not allowed.
Please use `gem yank` to remove bad gem releases.
So, I have checked and there is already a gem with such name. So, is there an easy way to rename the gem I have including changing the gem name in all generate by bulder files:
or if I should rename the files by hand, could you tell which are the critical ones?
Instead of renaming files by hand. As it is just a tutorial gem, I would suggest you to create a new gem with
bundle gem gotqn_first_gem
and just move your HelloWorld class in lib. And follow the rest of the commands suggested in Railscasts.
Don't forget that after renaming you need to call git add -A to update your files list.
The reason for that is because (unless that you have changed) your my_first_gem.gemspec have a line like that:
spec.files = `git ls-files -z`.split("\x0")
So, when you call gem build my_first_gem-0.0.1.gem, the above command will search for your older files and ignore the renamed ones.
I am trying to use this gem in my rails application, but when I add it to my gem file and try to use it I get an error saying that it did not found the methods required (I am using it inside a controller). Also require 'bn4r' does not help as rails tells me that it cannot load such a file, which is odd. I can access the library from the development console with no problems any idea as to why this happens?
After adding the gem to the Gemfile:
gem 'bn4r'
install it:
$ bundle install
Restart the server and use it like this:
BayesNet.new
I have already run gem install spreadsheet in my Rails project,but it still shows the error:
no such file to load -- spreadsheet
How do I solve this problem?
You'll need to edit your Gemfile to include:
gem 'spreadsheet'
Then you'll need to run bundle install to get that injected into the Gemfile.lock file.
My gem file looks like:
group :development, :test do
gem 'rspec-rails'
gem 'annotate-models', '1.0.4'
end
I ran 'bundle install' and it installed the annotate-models bundle.
If I type: annotate I get a command not found error.
If I type: bundle show annotate I get a 'could not find gem annotate in the current bundle.
If I type bundle show annotate-models it says it installed in:
/Library/Ruby/Gems/1.8/gems/annotate-models-1.0.4
typing:
annotate-models
doesn't work either.
I'm following along in railstutorial.org and got stuck at this point.
Edit: Better version (using Bundler to install it only for the current project)
Add gem 'annotate' to Gemfile
Run $ bundle install
Run $ bundle exec annotate
Edit2: Seems you have to explicitly specify annotate version for now, so in Gemfile put gem 'annotate', '2.4.1.beta1' (which is a prereleased beta gem that works with the latest version of activerecord as opposed to specifying the github repo directly)
Edit3: 2.5.0 final is out now, so hopefully no need to force a beta version any more, just getting the latest should work!
Old version (with installing the gem on a system level too):
If running Rails 3 the drill is:
Run $ sudo gem install annotate
Add gem 'annotate' to Gemfile
Run $ bundle install
Run $ annotate
Be happy :)
You should run the command inside your bundled environment with:
$ bundle exec annotate
Check out the man page for more details.
The most voted answer didn't fully work for me, as I was getting and additional error when follow the proposed solution:
undefined method `namespace' for main:Object (NoMethodError)
I'm including below what worked for me (I'm using Ruby 1.9.2 and Rails 3.1.3 under Ubuntu 11.10):
Install annotate
$ gem install annotate
Modify Gemfile adding the following line
gem 'annotate',
:git => 'git://github.com/jeremyolliver/annotate_models.git',
:branch => 'rake_compatibility'
Install bundle
$ bundle install
Now you can use annotate as follows:
$ bundle exec annotate
I'm new to this, but I was having this problem doing the rails tutorial, but by adding the gems bin path to the PATH env variable I was able to fix it. (Just like gertas said a few posts above)
First in the command prompt:
gem list -d annotate
and you'll get a result that says something like
: annotate-models (1.0.4)
Author: Dave Thomas
Rubyforge: http://rubyforge.org/projects/annotate-models
Homepage: h'ttp://annotate-models.rubyforge.org
Installed at: C:/ruby192/lib/ruby/gems/1.9.1
the key line is:
Installed at: C:/ruby192/lib/ruby/gems/1.9.1
So in this case add a /bin to that path, For example I used: C:\ruby192\lib\ruby\gems\1.9.1\bin is what you want to add to your PATH environment variable.
To change your PATH environment variable on Vista do the following go to: control panel >> system >> advanced system settings(link on the left). Once the box opens up,click the Advanced tab and then the Environment variables button. Then on the system variables find the PATH variable and click the Edit button. Since paths are separated by semi-colons, add
;C:\ruby192\lib\ruby\gems\1.9.1\bin
At the end of the variable value field.
It should look like
`some/path;some_other_path;C:\ruby192\lib\ruby\gems\1.9.1\bin`
when you finish
Save it, and close and reopen the command prompt. annotate and rspec started to work for me after that. Good luck.
For me the answer was this one:
http://news.railstutorial.org/model-annotation
Use
gem 'annotate', '2.4.0'
instead of
gem 'annotate-models', '1.0.4'
It looks like the gem name was changed at RubyGems.org.
I think your PATH env variable lacks path to gems bin directory.
I guess it should be: /Library/Ruby/Gems/1.8/bin
You can use it for Rails 4, add gem in your gem file gem "annotate", "~> 2.5.0" and run following command
rails g annotate_models:install
instead of
rails g annotate:install
Then run following command to add schema information after model class
bundle exec annotate -p after
or can use following for before
bundle exec annotate -p before
If bundle exec annotate doesn't work, try:
rake annotate_models