Skip to content
prusswan edited this page Mar 8, 2017 · 63 revisions

FAQs - Module 1

OSX and Linux

Windows

Multiplatform Web IDE

How to use Git

OSX and Linux


Q: How to write, save and quit using vi editor?

(PLEASE NOTE: Using vi editor is by no means a necessity and if you have a favorite editor of your own - feel free to use it. If you still would like to use vi...)

A: Here are a few basic commands:

Create/edit a file:

vi <filename>

If the filename exists, you will be editing the existing file; if not, it will create a new file

Moving arround: Vi works in two modes: command mode and insert mode. Command mode allows you to move arround.

To enter text, type the command i (for insert) and you will be able to type text.

To exit insert mode, press esc key

To save a file:

In command mode, type :w press enter

This will save the edits to the file but will not close vi

Quit vi:

In command mode, type :q

You will be prompt with a message asking if you want to save the file before quitting. Select Y/N

Aditional references:

Vi Cheat Sheet How to use vi Editor


Q: How to install PhantomJS on OSX El Capitan?

A: Install using NPM (Node Package Manager)

npm install phantom phantomjs -g

If you do not have NodeJS: brew install node

If you do not have NPM: brew install npm

For more information about this issue and other solutions: https://github.com/Homebrew/homebrew/issues/44535


Q: Problems installing rbenv/updating Rails/getting Git to work (Mac)

A: If you do not have Xcode, you need to install it:

xcode-select --install

If you have Xcode and gets an error about the license, you need to accept the terms:

sudo xcodebuild -license

Q: Why do I keep getting a message that 'rspec' command is not found?

A: If you are using rbenv, you need to run rbenv rehash every time you install a new version of Ruby or a gem that will provide commands, like rspec. (https://github.com/rbenv/rbenv#rbenv-rehash)


Q: How to install PhantomJS? (Linux)

A: If the error is when adding PhantomJS to path, please check which version you downloaded.

If it was 64 bit:

export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64" 

If it was 32 bit:

export PHANTOM_JS="phantomjs-1.9.8-linux-i686"

If curl throws an error about the SSL certificate:

curl -kL https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2 |tar xvjf

Or else, you can try the instructions here: https://gist.github.com/julionc/7476620


Windows


Q: What to do when Rails fails to update?

A: If you encountered an error when you ran the command gem install rails -v 4.2.8, you will need to download the SSL certificate.

Instructions here: Workaround RubyGems' SSL errors on Ruby for Windows

Another workaround is to run the following commands:

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem update --system

gem install rails -v 4.2.8

Q: How to solve "No source of timezone data could be found" error?

A: Add the following line to your Gemfile

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Then, run the command bundle to install the gem and restart Rails server

More information about this issue: https://github.com/tzinfo/tzinfo/wiki/Resolving-TZInfo::DataSourceNotFound-Errors


Q: How to add PhantomJS to PATH?

A: After downloading PhantomJS, extract the files to a directory that you will remember. Make sure that you choose a directory that has no space on its name.

  • Open phantomjs-2.0.0-windows directory and navigate to bin, inside which you will find phantomjs.exe.
  • Right click on the address bar and copy the address as text. If you extracted the files to C, for instance, the address will be C:\phantomjs-2.0.0-windows\bin
  • Click the Windows key and type "env". Select "Edit the system environment variables"
  • Click 'Environment Variables'
  • On "User variables for <your-username>, select "path", click "Edit..." and them click "Edit text..."
  • By the end of that line, add a ; (semi-colon) and paste the address of phantomjs
  • Restart your console
  • Type phantomjs -v to see if everything is OK.
  • WARNING: Please do not add phantomjs-2.0.0-windows folder under another folder with spaces in the name. "C:\Program Files" is a great example. There is currently a known bug for it.

Q: How to fix the "ExecJS::ProgramError"?

A: There is an incompatibility between recent versions of the CoffeeScript gem and Windows 64 bit. To fix it, you need to download and install NodeJS: https://nodejs.org/en/download/ After installing, you will need to restart your computer.


Q: "DL is deprecated, please use Fiddle"

A: The message above may pop up every time you start the console or when running a Rails command. This is not an error. It is just an alert, so there is no need to be concerned. If you want to get rid of it, there are a few suggestions here: http://stackoverflow.com/questions/15590450/ruby-2-0-0p0-irb-warning-dl-is-deprecated-please-use-fiddle/15601984#15601984


Q: How to resolve "CP850 Encoding Undefined Conversion Error"

C:\>gem install rails -v 4.2.8
...
ERROR: While executing gem ... (Encoding::UndefinedConversionError)

U+2019 to CP850 in conversion from UTF-16LE to UTF-8 to CP850

A: On windows, which is using other than US-English, this error may prevent you from installing gems.

Follow these steps to resolve the encoding issue:

  1. Run the following command in windows command prompt (as administrator).
C:\>chcp 1252
  1. Edit the file C:\RailsInstaller\Ruby2.1.0\lib\ruby\2.1.0\win32\registry.rb

Comment Line # 70 and replace as shown below:

#LOCALE = Encoding.find(Encoding.locale_charmap)
LOCALE = Encoding::UTF_8
  1. Close all windows command prompts and open a new prompt. Then run the gem install command again.
C:\>gem install rails -v 4.2.8

Q: Why do I get a message that the 'The system cannot find specified path' when I check the Rails version?

A: There are a few reasons for that error. The first thing to try in order to fix it is to install Rails:

gem install rails -v 4.2.8

If after installing Rails you still get the message, it might be the case that you will have to manually initialize the DevKit.

From your console, cd into the DevKit directory (it will be inside RailsInstaller folder). Then, run the following commands:

ruby dk.rb init
ruby dk.rb install

In case you get a message asking you to edit the config.yml file, open it and make sure that it looks like the following:

(...)
# Example:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
- C:\RailsInstaller\Ruby2.2.0 # it can be different on your computer
                              # but make sure it points to the Ruby directory
                              # inside RailsInstaller

After editing the config.yml, run ruby dk.rb install again.

If you still get the same message, it might be the case that you are using Cygwin. If so, try using the Git Bash as you main console.


Q: I get an ArgumentError and a NoMethodError when I try to install Rails

A: Please follow the instructions here


Q: How to fix the BuildError when creating a new Rails app?

A: Run gem update --system. Then check the version you have (gem -v). You will probably have the 2.5.2 and it should work OK. If not, downgrade it to 2.3 (gem update --system 2.3.0)


Q: Why I cannot see the Rails welcome page?

A: Start Rails server (rails s) and navigate to http://localhost:3000. If you see an error (AbstractController::Helpers::MissingHelperError), it might be related to a case sensitivity issue.

If you created you app inside a folder that has a capitalized name (it is the case if you are using the Sites directory created by RailsInstaller), you will have to change its name. Note that if you only change it to sites, the problem will come back after you restart your computer. The best way to fix it is changing the name of the folder.


Q: I'm getting a message that says, 'Checksum of /versions does not match' when I start Rails server

A: First, run gem unistall bundler. If you are unable to do it, add --force to the end of that command. Then, reinstall Bundler: gem install bundler. You can check the new version:

bundler -v
=> Bundler version 1.11.2

Q: How to downgrade Rails?

A: For the course, it is ideal that you use Rails 4.2.8, because it is the version used by the grader. You can uninstall Rails by running

gem uninstall rails
gem uninstall railties

An them install the version you will need:

gem install rails -v 4.2.8

If you have multiple versions of Rails installed, just add the version that you want to uninstall to the end of the command:

gem uninstall rails -v 4.2.5.1    # uninstall version 4.2.5.1
gem uninstall railties -v 4.2.5.1

Q: I ran rails new test_install but got message saying Could not verify the SSL certificate...There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificate...

A: This happens during the bundle install command that gets automatically called by the rails new command. At this stage, rails should have already created the folder structure and files that you need for the new project. So now, all you need is to edit the Gemfile inside test_install directory and at the top of the file, change the line from

source 'https://rubygems.org'

to

source 'http://rubygems.org'

After you make this change and save the file. Go back to the command line and run `bundle install'.

Clone this wiki locally