I'm on Windows 10 and am a complete beginner programmer. I am using Ruby 2.4.2, Rails 5.1.4 and am following a Lynda course on how to run Rails 5 on Windows.
There's a part near the end where the tutor says to enter:
>rails db:schema:dump
to test whether you've established a connection to the MySQL by create a file inside the created project.
This is what I get when I enter the above command:
C:\Users\notmyactualuser\Documents\Sites\demo_project>rails db:schema:dump
rails aborted!
LoadError: cannot load such file -- mysql2/2.4/mysql2
C:/Users/notmyactualuser/Documents/Sites/demo_project/config/application.rb:7:in `<top (required)>'
C:/Users/notmyactualuser/Documents/Sites/demo_project/Rakefile:4:in `require_relative'
C:/Users/notmyactualuser/Documents/Sites/demo_project/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
The tutor doesn't address what to do with potential errors and I can't seem to find an answer. I want to build a login form using RoR and am trying to grasp the basics (clearly failing). If possible, can I get help with the above and be directed to an easy, simple, "how-to" on building a login form?
Thanks a lot.
P.S. My first post, so please go easy on me, lol.
UPDATE: So I used the command on CMD and it looks like it's successful. Can somebody point me to how to get it working with Rails?
UPDATE 2: I put in the command that Hoa requested and I got this:
ERROR: "bundle install" was called with arguments ["mysql2"]
Usage: "bundle install [OPTIONS]"
UPDATE 3: I did as Satishkakumar said and I got this:
You've installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.1.6.
It's recommended to use the exact same version to avoid potential issues.
At the time of building this gem, the necessary DLL files were retrieved from:
http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.6-win32.zip
This gem includes vendor/libmysql.dll with redistribution notice in vendor/README.
======================================================================================================
Looks like it's all sorted now? Please let me know if there's any more.
I think its issue of installing mysql2 gem in system. Follow below steps to install.
In Gemfile add the line
gem 'mysql2', '0.3.21'
And run bundle install from project folder in CMD.
bundle install mysql2
This might solve your issue. Let me know in comment section if your issue still persists.
Related
I am setting up a machine running:
ruby 3.0.4-p208
passenger 6.0.14
redmine 5.0.1.stable
redmineUP latest version of all plugins
mysql2 5.7
I'm trying to install redmineX, which theoretically plays well and requires redmineUP. RedmineUP is installed and is more-or-less running. I'm having an error during the install:
bundle exec rake redmine:plugins:migrate RAILS_ENV=redmine_test
fails with the error:
cannot load such file -- redmine_x_ux_upgrade/view_projects_hook (LoadError)
/home/test_user/.gem/ruby/3.0.4/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
/home/test_user/.gem/ruby/3.0.4/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
/home/test_user/.gem/ruby/3.0.4/gems/activesupport-6.1.6/lib/active_support/dependencies/zeitwerk_integration.rb:51:in `require_dependency'
/home/test_user/redmine-5.0.1/plugins/000_redmine_x_ux_upgrade/init.rb:22:in `<top (required)>'
/home/test_user/redmine-5.0.1/lib/redmine/plugin_loader.rb:31:in `load'
- GEM PATHS:
- /home/test_user/.gem/ruby/3.0.4
- /opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0
The file in question exists:
/home/test_user/redmine_test/plugins/000_redmine_x_ux_upgrade/lib/redmine_x_ux_upgrade/view_projects_hook.rb
Ideas?
Since this is occurring at the bundle exec rake, rather than in the redmine app, I'm assuming this issue is with the user GEM_PATH. I've tried tweaking GEM_PATH to also contain
/home/test_user/redmine_test/
/home/test_user/redmine_test/plugins/
with no success.
This turned out to be a versioning problem; using plugins written for redmine 4.x in a redmine-5.x environment.
The main problem was the vendor's helpdesk reformatted email so well-formatted plain-text with blank line separated error and log output ended up all run together. After turning all logs, error output, directory listings, etc. into separate files and attaching them, they could read the main part of the mail and identify the problem.
I downloaded and installed Ruby 2.5.7-1 (x64) on a Windows 10 system from the following site:
https://rubyinstaller.org/downloads/
I then installed Rails and Bundler as follows:
gem install rails -v 5.2.3
gem install bundler
I then ran bundle install. This all worked fine.
However, after all that, when I try to run rails db:migrate or rails server, I get the following message:
rails aborted!
LoadError: Could not open library 'libcurl': The specified module could not be found.
.
Could not open library 'libcurl.dll': The specified module could not be found.
.
Could not open library 'libcurl.so.4': The specified module could not be found.
.
Could not open library 'libcurl.so.4.dll': The specified module could not be found.
C:/path-to-app/config/application.rb:18:in `<top (required)>'
C:/path-to-app/Rakefile:4:in `require'
C:/path-to-app/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
When I Google this error, everything seems to point to the following SO post and top answer:
How to solve 'libcurl' not found with Rails on Windows
I downloaded several versions of libcurl.dll, placed them in the C:\Ruby25-x64\bin directory, restarted the DB server, restarted my IDE with terminal, and tried again, but I still keep getting the same error.
I've also confirmed that C:\Ruby25-x64\bin is part of my user Path variable, but I'm still getting this issue.
Does anyone have any ideas on how I can resolve this, since the SO post linked above either doesn't work (or I'm not doing something that's obvious)? Thanks.
I'm trying to install Ruby on Rails, but when I want to use Ruby, install bundle, or create a Rails app, I get this error:
C:/Ruby22-x64/lib/ruby/2.2.0/win32/registry.rb:71:in `find': unknown encoding name - CP720 (ArgumentError)
from C:/Ruby22-x64/lib/ruby/2.2.0/win32/registry.rb:71:in `<module:Win32>'
from C:/Ruby22-x64/lib/ruby/2.2.0/win32/registry.rb:3:in `<top (required)>'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from dk.rb:1:in `<main>'
Welcome to Stack Overflow! Very glad that you decided to try Ruby and Rails.
Long story short, you're on Windows and there's a lot of caveats to get the Ruby on Rails stack running on this OS. I think you probably tried to install Ruby just by itself... Could you please try removing that and installing the bundle from http://railsinstaller.org/en instead? It will save you a lot of headaches like these in the long run. I've used it and it's a very well thought out package.
Let me know how it works out for you, cheers!
this is because of the default code page of your command terminal.
use the below command to change the code page to Windows-1252 and you will not longer get that error
chcp 1252
I am trying to run a Rails 2.3 app locally.
script/server gives me these errors:
bash: script/server: Permission denied
bash: parse_git_branch: command not found
script/server gives me the error:
/Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': cannot load such file -- initializer (LoadError)
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:55:in `load_initializer'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:38:in `run'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:11:in `boot!'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:110:in `<top (required)>'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `<main>'
bash: parse_git_branch: command not found
Any ideas of how I can get this to run locally?
This question is what I've been doing for the past month. I would have loved to use Rails 4, but I know better than to try it!
Install rvm or rbenv, then get into a server that correctly runs this app, and run
ruby --version
gem list > ~/myGems.txt
Using rvm or rbenv, install the exact same version of Ruby.
(Tip: whenever I say "exact same", you can fudge by bumping the revision. For example, given a gem with version 0.1.4, if it has subsequent versions 0.1.5, 0.1.6, and 0.2.0, you can bump to 0.1.6, if that will save you some grief. The revision numbers, 0.1.*, are supposed to be only bug fixes. But a minor version bump, 0.2.0, has higher odds of breaking things. I kept the same version of Ruby, but I bumped rails to 2.3.14.)
Using rvm or rbenv, install the same version of Ruby as currently runs on this app's main server.
Inside this Ruby environment (with both which ruby and ruby --version reporting the correct answers), install each gem in myGems.txt, like this:
gem install --ignore-dependencies --no-rdoc --no-ri my_gem -v=0.1.4
The --ignore-dependencies is critical, because some gems from the Pleistocene Epoch, 2009, don't specify their dependencies' versions. When some dumb 2009 gem pulls in the 2013 rake, you will be utterly screwed, because reverting that rake is really hard. And don't forget to set the -v to the same value as myGems.txt reports!
After all that, try simple rake commands like rake routes. Post any bugs you get as fresh questions, but remember to point out Rails 2.3 in the subject so nobody mis-answers with the modern fixes.
And if this app has tests or specs, getting them running should be a top priority, so you can resume TDD, leaning on the tests to allow you to make sick changes.
I'm all of the sudden getting the follow error message when I try to load the rails console. I just recently switched databases to postgres, which has given me a slew of problems (although I must admit I like it a lot better than mysql!), so I'm assuming this is related to that. Any ideas?
y (Errno::ENOENT)/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require': No such file or directory - /usr/local/lib/?
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processing.rb:3:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:5:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/environment.rb:1:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/sprockets/railtie.rb:23:in `block in <class:Railtie>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `run'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `each'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:136:in `initialize!'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/benyorke/rubystore/config/environment.rb:6:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require_environment!'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I believe this might be a bug with Ruby 1.9.3-p327 that just got fixed by Ruby 1.9.3-p385. Does upgrading to 1.9.3-p385 fix it for you?
What seems peculiar in this error message, and is similar to issues I've been having, is the question mark at the end of the path: No such file or directory - /usr/local/lib/?. I've been getting similar strange error messages related to ruby's require and paths with question marks, at symbols, or other random characters at the end of paths after upgrading to 1.9.3-p327 from 1.9.3-p194 a few weeks ago. However, the issues have been extremely sporadic, and around the same time we experienced some hardware failures, so it's been tough to track down.
Today the issue started happening consistently in one specific context, so I was able to do some additional debugging. Updating to 1.9.3-p385 seems to have fixed it, but given the sporadic nature of the issues I've been experiencing, I'm not entirely 100% this is actually the fix. I'm also not entirely sure if this is the same issue you're having. The mysterious question mark in the path just makes it appear like it might be related. Here are a couple examples of the type of errors we were getting:
No such file or directory - /srv/shared/rails/internal/admin/vendor/bun#
No such file or directory - /srv/shared/rails/internal/admin/vendor?
If it's at all related to the same issues I've been experiencing, but the 1.9.3-p385 upgrade doesn't fix it, a few other notes or things to explore:
I was able to reproduce this problem today on 1.9.3-p327 and 1.9.3-p374. However, the problem didn't seem present on 1.9.3-p194, 1.9.3-p286, and 1.9.3-p385.
Are you using symlinks anywhere in in your gem load path? For example, we use Bundler to install gems into a local vendor/bundle path inside each application. But the vendor/bundle is actually a symlink to another location (this is related to a Capistrano deployment setup). I believe the symlink was possibly playing a role. In today's tests, if I wasn't using a symlink, the problem disappeared on all versions of ruby.
Do you use bundler-exec? On another occasion where this problem was happening somewhat sporadically, bypassing the aliases bundler-exec also seemed to magically fix things, but today's problem wasn't even touching bundler-exec, so I'm not too sure.
Most of the time our problem was very random (it would go away after a few attempts of running the same command), but on a few occasions, the problem would persist for an hour or more before disappearing.
Some information about our systems:
64bit RedHat Enterprise Linux 6
Bundler 1.2.3
Rubygems 1.2.5 (also happened under 1.2.4)
rbenv
But like I said, this issue also happened to coincide with some hardware disk failures and general server wonkiness on our end, so I haven't really been certain if this was a Ruby issue or what's been going on. But here's to hoping 1.9.3-p385 actually fixes it.
Sorry for not updating this thread - I have actually been working on this in the background for a few weeks now. I couldn't find ANY information on this online, so I'm going to post as detailed of a solution as I can.
The Issues
The issues I was having was that I could not access rails console, and I had to manually start the postgres server every-time I restarted my machine. My solutions to that, as I have worked with this for a few weeks were
In regards to the console I used herokus console. By pushing my app to heroku (which is free) not only could I view it on the web (any machine) but on my machine I could run
$ heroku run console
and get access to a console. Now this isn't a perfect solution in anyway as I can't manipulate data on my machine but it saved me many times
In regards to the server I ran
$ brew info postgres
which gave me the commands to manually restart the server
You should reload postgresql:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
The Solution
To be honest, I have run every command I can find dozens of times, and just today got it working. I don't know if I was making typos, doing it in an ineffective order, mixing up pg/postgres/postgresql or what but what I did below worked
When using this solution, it will erase all databases. Migrations will be able to rebuild the structure, but any data will be lost
1. Updated Homebrew
$ brew update
If you don't have home-brew, check out this page for instructions to install (saved my neck with many things, including minimagick imagemagick and postgres!): Link
2. Removed postgresql
$ brew rm postgresql --force
3. Installed postgreql
$ brew install postgresql
This is the first step to reference postgres. When looking online, I ran across commands that used postgresql, postgres, and pg. Postgresql refers to the actually PostgreSQL program. postgres and pg are ruby gems, which we will get to later
4. Ran suggested commands
After running "$ brew install postgres" there is a lot of information given to you. Make sure to read through it, as it will suggest what commands to run. Use these suggestions to find the commands I reference below.
If you need to access this information later simply run
$ brew info postgresql
To initialize the database
$ initdb file/path
Set up the autolauncher
$ cp file/path ~ LaunchAgents/file/path
Launch postgresql initially
$ launchctl load file/path
$ pg_ctl-D file/oath
5. Download Postgres.app
Although to my knowledge this seems redundant, this is what got it to work on my mac. visit http://postgresapp.com to download
6. Install gems
There are two gems - postgres and pg. I required pg in my gemfile and ran a bundle install command, however it still gave me issues until I installed postgres on my machine - even though it is not required in my gemfile, rails console wont seem to work without it atleast installed
In the gem file
gem 'pg'
Run a bundle install command in a terminal window
$ bundle install
Sudo install the postgres gem
$ sudo gem install postgres
At this point everything should be working. You should be able to restart the machine and not have any problems!