0

First of all I like to say that I am absolutly begginer in Ruby and I need to do some modifications.

Just to know, I am using windows 7.

I have installed the Foundation 5 gem in my Ruby, but when I try to run the command foundation new projectName I am gettings the error The system cannot find the path specified.

After a long research I have find that Foundation gem, is creating the project folder, then generating the appropriate files, and finally trying to run the command bower install from the parent folder, not from inside the project folder, that contains the bower.json.

More specific, lets say I am in folder C:\Test\ and I am running the command

foundation new myApp

The foundation gem, will build the folder myApp and inside this folder will generate all the required files.

Finally, while I am in C:\, foundation gem, will try to run the command

bower install

while the bower.json located under the folder C:\TEST\myApp\

Currenly what I am doing, is to modify the generator.rb file from Foundation gem, to set the location of the file bower.json.

I have try any of the following, but none working:

run("#{name/}bower install", capture: true, verbose: false)
run("/#{name/}bower install", capture: true, verbose: false)

where #{name} in this example is the myApp.

Is there any way to say "Change Directory and go to the project dir before run the command bower install" ?

Can somebody please help me ?

Stoic
  • 10,536
  • 6
  • 41
  • 60
KodeFor.Me
  • 13,069
  • 27
  • 98
  • 166

2 Answers2

3

try: Dir.chdir method. Reference: http://www.ruby-doc.org/core-2.1.0/Dir.html#method-c-chdir

Dir.chdir(directory) do
  run("bower install", capture: true, verbose: false)
end

The above example code will change to the directory represented by the directory variable, and then run whatever commands you pass to this block.

Stoic
  • 10,536
  • 6
  • 41
  • 60
  • How to use the dirname ? In my case the variable `name` contains the new folder name. Sorry for this question, but I don't event know the Ruby Syntax. Should I use bracets ? – KodeFor.Me Dec 27 '13 at 17:34
  • Also, should I include any external library ? of the Dir is by default available in Ruby ? – KodeFor.Me Dec 27 '13 at 17:34
  • @MerianosNikos: `Dir` is available by default in ruby. Also, where is this script located, i.e. which directory will contain the code for this `run` command? That can help me create the `directory` variable for you. – Stoic Dec 27 '13 at 17:36
1

You should look into running Ruby from VirtualBox. I started with Ruby on Windows 7 and it was problem after problem. Now, I'm still on Windows, but we run all Ruby from Ubuntu Linux VirtualBox with a Vagrant script and it works much better.

Download Console2 from http://sourceforge.net/projects/console/

and Git Bash from https://openhatch.org/missions/windows-setup/install-git-bash

Then make Console default to Git Bash Shell by going to Edit->Settings, then paste this in the Shell field:

"C:\Program Files (x86)\Git\bin\sh.exe --login -i"

With this setup you'll get basic Linux commands. Run locate bower and this should tell you where bower lives. Add that path to your Path in your Environment variables. You also should use Console2 for running your Ruby instead of command prompt.

rdaniels
  • 939
  • 8
  • 7