I'm trying to get get going on a rails tutorial and get get past the installation. I'm a newbie.
1 . ran "rails new app1." - The app is created but bundler fails (looks like it is run as part of the rails new command
An error occured while installing sqlite3 (1.3.5),
changed the gemfile to explicitly call for "gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' (this is the most recent version that works on osx 10.5)"
ran "bundle install" - success
try to view the default app and see the error
ActiveRecord::ConnectionNotEstablished
looked in config/database.yml. It says "database: db/development.sqlite3"
looked in db/ - no database here. - - Is a db supposed to be created during rails new?
Tried running rake db:migrate - get
"rake aborted!
: Please install the sqlite3 adapter: gem install activerecord-sqlite3-adapter (sqlite3 is not part of the bundle. Add it to Gemfile.)"
Tried running that command, got
ERROR: Could not find a valid gem 'activerecord-sqlite3-adapter' (>= 0) in any repository
ERROR: Possible alternatives: activerecord-jdbcsqlite3-adapter, activerecord-sqlserver-adapter, activerecord-spatialite-adapter, activerecord-n
ulldb-adapter, activerecord-dbslayer-adapter
Anyone know what I'm missing?
Anybody have an idea what I need to do?
OSX 10.5.8 (leopard)
rails 3.2.0
ruby 1.9.2
Well that last part is a bit hairy sounding, but to get your database sorted you want:
rake db:setup
...not migration, to create the database.
rake -T | grep db
...shows you the options, for future reference. Let's see what happens after that :)
Related
I was trying to learn ruby on rails, so I installed the gem version 4.0.0, when I start my server, and go to localhost:8000, it brings me an error page with error message:
ActiveRecord::ConnectionNotEstablished.
I'm using sqlite3, not MySQL. Any help is appreciated.
edit: i fixed it, had to do with my database.yml
Make sure that you have installed sqlite3 gem: gem install sqlite3 or run bundle install if you have the gem listed on your Gemfile (which you should).
After that run the following commands:
rake db:create # creates the database
rake db:migrate # creates the tables based on your migration files
If the above two works fine, your application should be able to connect to the database. If not you probably have a configuration problem on your config/database.yml.
I am trying to start database and still learining ruby on rails. But in this step I've got an error when running following code in cmd.
I have installed mysql2 and it is appeared in gem list. I put database.yml file in the tutorial sample files to my working folder. Still got the error. And installed all mysql2 again. installed bundle again.
Note: I'm using Windows 8.1 64 Bit.
C:\Users\Thilanka\myapp>rake db:schema:dump
DL is deprecated, please use Fiddle
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not load
ed. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum
required by ActiveRecord).
Gem::LoadError: mysql2 is not part of the bundle. Add it to Gemfile.
Tasks: TOP => db:schema:dump => db:load_config
(See full trace by running task with --trace)
Please ensure that you have the following line in your Gemfile:
gem 'mysql2'
Run bundle install once you added that line to your Gemfile.
You might want to read the install notes for Windows if you still have problems.
I'm not sure about how Windows behave in this case but from my experience (still learning RoR and I'm in the middle of a migration between sqlite and mysql).
The first thing I did was install mysql on my computer, then as #spickermann said declare the gem in the Gemfile and run bundle install.
For the error you show (Gem::LoadError: mysql2 is not part of the bundle. Add it to Gemfile.) it seems that you missed the Gemfile step.
Background:
I get errors whenever I run rake in an older project. (uninitialized constant Rake::DSL).
The rails project in question is an old project that was started with Rails 2.1 (I think), and since then I've updated the OS on my laptop a couple of times, and made updates along the way to make it run.
Right now, the rails app works fine, provided I have RAILS_GEM_VERSION set to 2.3.5. I'm not sure if the app was completely updated to Rails 2.3.5.
There is no Gemfile in my older project.
If I create a brand-new rails project (and unset RAILS_GEM_VERSION), rake runs fine.
My question: To troubleshoot, I'd like to try newer versions of rake. I'd like to know how to force one specific version to be used, since it appears I have multiple versions installed.
Info on my environment:
$ gem list rake
*** LOCAL GEMS ***
rake (0.9.2.2, 0.9.2, 0.8.7, 0.8.3)
$ rake --version
rake, version 0.8.7
So it looks like it's picking up the 0.8.7 version.
All the help files online seem to tell me to specify the rake version in the Gemfile, but there isn't one in this project. (Maybe it predates gemfiles?)
If I unset the RAILS_GEM_ENVIRONMENT variable altogether, and try to run rake, I get:
rake aborted!
can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.2.8 for []
None of the environment config files in my older project set that variable either.
This may be of help. Have you tried the underscore solution?
Example:
rake _0.9.2_
you can run rake specific version by using this
bundle exec rake ...
more detail see this - bundle exec, rake
You can uninstall the current version of rake and install another desired version using commands similar to the following:
gem uninstall rake 12.3.1
gem install rake 10.5.0
(Note: you might need to run as sudo for permissions)
I had a problem where I received the following error while trying to install rake 10.5.0:
Could not find a valid gem '0.8.7' (>= 0) in any repository
I resolved this problem by adding the following line to my Gemfile:
gem 'rake', ' <11.0'
After editing Gemfile I was able to successfully downgrade rake by updating my gems:
bundle update
I'm running on Rails 3.1.1 and ruby 1.9.2 on Mac OS and just started a new project where I want to use gettext for translations.
I followed every step when using fast_gettext described here: https://github.com/grosser/gettext_i18n_rails
The installation and everything works find. But when I try to rake gettext:find I get this error message:
$ bundle exec rake gettext:find
rake aborted!
undefined method `add' for "/Users/Olaf/.rvm/gems/ruby-1.9.2-p0":String
Tasks: TOP => gettext:find
I also have to use bundle exec when performing any kind of rake task, I have the problem described here:
rake db:create Not working
Maybe that is related.
Has anyone an idea what is going on? I'm a bit desperate, sitting here since hours trying to figure it out. Google doesn't deliver any hints.
Thanks!
Olaf
I was having similar issues. I believe it comes down to an incompatibility between gettext and more recent versions of RubyGems (1.8+). There is a pull request that addresses this issue, but unfortunately it hasn't been merged yet.
In the meantime you can try adding the fork (and the commit that resolves the issue) as a dependency in your Gemfile:
group :development do
gem 'gettext', git: 'https://github.com/cameel/gettext.git', ref: 'c3a8373'
gem 'ruby_parser'
gem 'locale'
end
Install
gem 'gettext', '>=3.0.2'
As it is specified on https://github.com/grosser/gettext_i18n_rails#optional
I get this error when launching my Mongrel server...
$ script/server --debugger
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
config.gem: Unpacked gem authlogic-2.1.3 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
=> Debugger enabled
=> Call with -d to detach
=> Ctrl-C to shutdown server
When I run rake gems:refresh_specs like it suggests I get another error though:
rake aborted!
undefined method `installed_source_index' for #<Gem::SourceIndex:0x100551a58>
Any thoughts on how to fix this?
I am not sure why it is broken in Authlogic, but I had to generate it myself.
Try this in your Rails project:
$prompt> cd vendor/gems/authlogic-2.1.3
$prompt> gem specification authlogic > .specification
I'm just going to chime in here, because I experience the same thing today, except with a different gem.
I was updating hoptoad to use the notifier as a gem instead of a plugin, and one of the instructions from the Github page is to unpack the gem into vendor/gems.
I'm on Mac OS X, and I unpacked the gem as so:
$> rake gems:unpack GEM=hoptoad_notifier
After I did this, I got the error specified, and the gem didn't actually unpack (it created the directory in vendor/gems, but didn't actually unpack the gem).
I deleted the directory from vendor/gems, and tried again as:
$> sudo rake gems:unpack GEM=hoptoad_notifier
Worked this time, unpacked properly, and no error.
I believe this is the reason:
http://github.com/binarylogic/authlogic/commit/05e452472616bd60bb81affc75a1cb3d95cf7857
The owner purposely added the gitignore on the .specification file.
I'm guessing u freeze this particular gem and submit it in your code branch under vendor/gems/..and as expected, git ignore this particular file per request
I had to pop into vendor/gems/authlogic and remove '.specification' from the .gitignore
Once you've done that you can run rake gems:refresh_specs
Only problem is that the next time you upgrade this gem the bad .gitignore comes back
I had the same "unknown GEM" problems. After much faffing about I found the following recipe :
First, I installed the gem using the standard "gem install authlogic", which placed the gem in /Library/Ruby/Gems/1.8.
Within RadRails, I used the rake task "gems:unpack" which seems to gather all the gems relevant to your app and place them in /vendor/gems as desired.
I then uninstalled the system wide gem to check it has really worked with : gem uninstall authlogic --install-dir=/Library/Ruby/Gems/1.8
Seems to work well.
Build and install the gem before generating the .specification file
$prompt> cd vendor/gems/authlogic-2.1.3
$prompt> gem build authlogic.gemspec
$prompt> gem install authlogic.gemspec
$prompt> gem specification authlogic > .specification