0

I'm setting up my first Ruby project on Team City, which is hosted on a Windows Server, but I'm having a problem. Now, because the server may not have the required gems installed, I've added a command line build step:

bundle install

Now I thought this would be enough, but apparently bundle is not recognized as an internal or external command. Except, if I RDP into the server, if I run bundle install from anywhere, it is fine, and just notifies me that no gemfile was found.

Any ideas on if I've missed a step, or I'm going about this the wrong way?

ediblecode
  • 11,701
  • 19
  • 68
  • 116

1 Answers1

2

Most likely this is a problem with TeamCity not finding the path to ruby executables.

You can address this by overriding the value to the PATH environment variable in your build configuration in the Build Parameters section.

env.PATH=/path/to/ruby;%env.PATH%

See this answer for the proper links to documentation, etc.


EDIT #1

I noticed when updating one of my configurations that TeamCity is supposed to take care of appending values so you DO NOT need to set path equal to itself. The post mentioned above is a workaround for a bug where TeamCity was overwriting the values, but that has been corrected. See the help at the mouse-over for more information:

Mouse-over help for Environment Variables


EDIT #2

I tested edit #1 and found that is not the case. You do need to

  • create an environment variable env.Path
  • and set it's value to itself plus your new path; in my example, C:\Program Files\MySQL\MySQL Server 5.6\bin\;%env.Path%
  • you do NOT need to say env.Path=... as listed above; that is what the configuration file will look like.

I tested this out by doing the following:

  1. Created a new project with no repository
  2. Added a command line build step to `echo %env.Path%
  3. Added a command step to call MySql mysql --help This will fail if it cannot find MySql

I then ran it for each of the following settings for the env.Path variable:

  1. Not added / changed; TeamCity reports out the environment variable for the build agent as is.
  2. Added as just C:\Program Files\MySQL\MySQL Server 5.6\bin\. TeamCity reports out only that entry.
  3. Added as C:\Program Files\MySQL\MySQL Server 5.6\bin\;%env.Path%. TeamCity prepends C:\Program Files\MySQL\MySQL Server 5.6\bin\ to the build agent's values shown in #1. The result is what we want, #1 + #2
Community
  • 1
  • 1
Damon
  • 1,249
  • 1
  • 15
  • 27
  • Note that the referenced answer uses a colon `:` between the prepended path and the existing PATH, but I think you need a semi-colon `;` instead, since that's what Windows uses to separate the different entries in the PATH variable. If you find that one works and the other does not, please edit this post or add a comment. – Damon Nov 16 '13 at 16:36
  • I've tried `env.PATH=C:\RailsInstaller\Ruby1.9.3;` but I'm not sure if I am using this properly? Is the path the bin the actual `ruby.exe` or...? – ediblecode Nov 18 '13 at 09:52
  • Yes, you should be looking for where Ruby installed to, not the installer. When you RDP in, run `WHERE bundle` to see the path that Windows is using. `WHERE` should be available on all modern flavors of Windows I think. I'm not using Ruby on any of my machines, otherwise I would test that out for you. I just saw a similar error with the build agents before, so I think that's all you need. Also this is marked accepted, so does that mean it worked for you? – Damon Nov 18 '13 at 20:51
  • I just noticed while updating env.PATH on one of my build configurations that the values you put here are supposed to be appended by Team City; the link I mention above is based on a work-around for a bug. So, you should just need to put the correct path for Ruby in the value and not worry about appending it; TeamCity should handle that. I'm updating the post to reflect that. – Damon Nov 18 '13 at 23:02
  • @jumpingcode Note that **Edit 1** is incorrect. I've left it in place for completeness, but corrected it with **Edit 2** – Damon Nov 19 '13 at 16:55