Installing Ruby on Rails on Windows via CYGWIN - ruby-on-rails

I am attempting to follow instructions on this page:
http://www.agilereasoning.com/2011/05/25/ruby-on-rails-on-windows-7-using-cygwin/
I have been trying to install Rails with varying success first using the railsinstaller and I encounter difficulties like no vim and I couldn't copy and paste from the Windows command prompt so I install CYGWIN. It didn't download the files correctly so I downloaded them manually and some were hard to locate. I couldn't find the final package as a .tar file so I downloaded libxslt-devel-1.1.20-1.i386.rpm.
Right click the Cygwin shortcut and choose edit from the menu. Change the contents to >match:
1 #echo off
2 C:\cygwin\bin\rxvt -sr -sl 1500 -e C:\cygwin\bin\bash.exe --login -i
Do I have to put this as a command to run on the executable or inside the cygwin commmand prompt? When I try to do that I get this:
-bash: 'command': command not found

Lots of things wrong here.
You can copy/paste the command prompt with Edit->Mark or Edit->Paste
libxslt-devel-1.1.20-1.i386.rpm is a linux file.
C:\cygwin\bin\rxvt - why are you mesing around with rxvt?
I recommend you install the rubyinstaller + devkit and then do gem install rails. However don't expect to be happy with rails' performance on windows.

Ruby on Rails on Windows via CYGWINTry:
Install Vagrant
Virtual Box,
and Cygwin (or PuTTy, I am using Cygwin).
With this set, open Cygwin, go to your project folder, run vagrant init <box> (my box is hashicorp/precise64 - see others)
(you may also want to cfg your Vagrantfile?). All set, Run: vagrant up and vagrant ssh
Now you have a virtual machine (Ubuntu) running, and you can install rvm (recommended... so you can have different versions of Ruby), or go directly with ruby, rails, etc.. (sudo apt-get ruby -v x.x.x,etc)
- Vagrant "creates and configures lightweight, reproducible, and portable development environments".
- Cygwin helps with ssh issues, etc...
- Virtual Box manages the machine (Ubuntu, or other OS)
With this set, I have no problem at all running Ruby (on Rails) with Windows.

Related

asdf-erlang doesn't install man pages

I am using asdf + asdf-erlang as my version manager for Erlang. All seems to be working fine, except that typing erl -man mnesia results in No manual entry for mnesia.
I have installed all dependencies mentioned on the asdf-erlang github page. I have also installed xsltproc and fop. Unfortunately "man" folder located under ~/.asdf/installs/erlang/18.3/lib/erlang/erts-73/ is empty. I haven't found man pages being generated elsewhere.
I was trying to locate build log, but I was not successful with that either.
I am using 64bit Ubuntu 16.10 & 16.04.
OK. I finally managed to resolve the issue:
Go to https://www.erlang.org/downloads/ and download manpages for the version(s) of Erlang you have installed using asdf (so for 18.3 you're looking for: http://erlang.org/download/otp_doc_man_18.3.tar.gz)
Copy man folder with its content (extracted from the archive) to ~/.asdf/installs/erlang/<version>/lib/erlang/. After doing so, you should have .~/asdf/installs/erlang/<version>/lib/erlang/man containing man1, man3, man4, man6, man7 (and each of those folders should have some manpages in it).
Repeating steps above for all the versions installed using asdf, allows you to use manpages for specific version of Erlang you are using at the moment.
looks like erlang-manpages are not included in the asdf-erlang since you are using ubuntu i would suggest you add Erlang Solutions repository to your system, call the following commands:
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
then install erlang-manpages:
sudo apt-get install erlang-manpages
you could also install erlang-doc — HTML/PDF documentation
sudo apt-get install erlang-doc
check this page for more information
The man path in #MaciekTalaska 's answer seems not correct, it does not work at all, for erlang 18.3.
After reading ASDF's activate script(), here's one statement:
_KERL_MANPATH_REMOVABLE="$HOME/.asdf/installs/erlang/18.3/lib/erlang/man:$HOME/.asdf/installs/erlang/18.3/man"
Therefore, you just need to:
Go to https://www.erlang.org/downloads/ and download manpages for the version(s) of Erlang you have installed using asdf (so for 18.3 you're looking for: http://erlang.org/download/otp_doc_man_18.3.tar.gz)
Copy man folder with its content (extracted from the archive) to $HOME/.asdf/installs/erlang/${version}, but not $HOME/.asdf/installs/erlang/${version}/lib/erlang/ (in fact, there isn't a folder named erlang under lib).

Wkhtmltopdf in a Dokku app?

I have a NodeJS/Express Dokku container. I'm trying to use a node module which just runs the wkhtmltopdf command from shell, but it can't find wkhtmltopdf.
Anyone have any experience with this?
You need to check how wkhtmltopdf was installed in that image.
As mentioned in node-wkhtmltopdf issues 32:
The wkhtmltopdf command is executed as a shell command on non-Windows systems.
Make sure the /usr/local/bin directory is in your $PATH variable. Do this by running:
$ sh
sh-3.2$ which wkhtmltopdf # Or try:
sh-3.2$ echo $PATH
sh-3.2$ exit
(In your case, you can do a sudo docker exec -it <containerIdOrName> sh)
The same issue adds:
What I ended up doing was downloading the dmg directly from wkhtmltopdf and that seemed to do the trick.
That means you might have to create a new image from the current one, installing wkhtmltopdf that way (with the dmg package)
jsonfry what installing wkhtmltopdf as a service container means: openlabs/docker-wkhtmltopdf-aas illustrates the installation process.
I got into the same issue as you did. I didn't want to run wkhtmltopdf in another container nor did I want to change the code to use remote calls. Since downloading wkhtmltopdf using apt-get plugin may result in a package that throws errors, I have created a new plugin that should set up wkhtmltopdf in the dokku container for you.
It is licensed using MIT license so feel free to do whatever you want. Hopefully it will help somebody.
URL: https://github.com/mbriskar/dokku-wkhtmltopdf

rails s command does not run from ssh

I am using Putty to connect to my localhost, and I don't have any problems apparently, however, when I run command rails s to start my rails 4.0.0 application from Putty, it gives me this message:
jose#jose-laptop:~/rails/dedicated-agenda$ rails s
The program 'rails' can be found in the following packages:
ruby-railties-3.2
ruby-railties-4.0
Try: sudo apt-get install
I don't get that message from the terminal though, the application starts running just fine.
I had to reinstall ubuntu so I upgraded to ubuntu 14.04 just in case you need to know.
I don't know if I am missing something in my ssh settings or how could I use rails s from Putty.
Thanks in advance.
Your PATH environment variable is set differently when you are executing programs in an interactive shell and by ssh(using putty).
Use absolute path of the program to not depend on the PATH variable.
You can also set the right PATH variable at ~/.profile file and load the updated variables using the command source ~/.profile.
Now, you should be able to run the command.
You can use the command
>which rails
to see where rails is installed on your working session.
Then you need to make sure that is in your path when you ssh in.
If you are ssh'ing in as a different use then that user may not have permission to see the rails executable.

How do I configure Cygwin to search using the PATHEXT environment variable?

I am trying to run Rails under Cygwin but when I type "rails -v" it finds "rails" and throws an error. When I type "rails.bat -v" it works just fine. Either works fine in the native Windows command processor because it uses PATHEXT to identify executables like .BAT.
I added a line to .bash_profile as follows and it is setting the variable, as far as I can tell.
export PATHEXT=".RB;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
This is my output:
$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software/syswow64:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/cygdrive/c/Program Files/Microsoft Windows Performance Toolkit:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files/7-Zip:/cygdrive/d/sysinternals:/cygdrive/d/batch:/cygdrive/d/Program Files/Sublime Text 2:/cygdrive/d/RailsInstaller/Ruby1.9.3/bin:/cygdrive/d/RailsInstaller/Git/cmd:/cygdrive/d/RailsInstaller/Git/bin:/usr/bin:/cygdrive/d/batch
18:54~
$ echo $PATHEXT
.RB;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
18:54~
$ which rails
/cygdrive/d/RailsInstaller/Ruby1.9.3/bin/rails
18:54~
$ which rails.bat
/cygdrive/d/RailsInstaller/Ruby1.9.3/bin/rails.bat
18:55~
$ rails -v
D:\RailsInstaller\Ruby1.9.3\bin\ruby.exe: No such file or directory -- /cygdrive/d/RailsInstaller/Ruby1.9.3/bin/rails (LoadError)
18:55~
$ rails.bat -v
Rails 3.2.11
18:55~
$
It looks like you're using the Railsinstaller ruby binary, which is basically a redistribution of RubyInstaller with some of the essentials for Rails development bundled.
However, everything is actually working as intended.
Cygwin doesn't won't use PATHTEXT because it doesn't need to. In other words, it will call the rails binstub instead of the rails.bat batch file. Since there is a hashbang in the binstubs, cygwin handles the entire execution itself.
Also, the RubyInstaller distribution wasn't compiled for Cygwin. So ruby.exe doesn't understand the look-up of the Cygwin paths. That is why you're getting a LoadError.
In my opinion, you should probably check out this answer by Luis Lavena to a similar question. However, if you really want to, you can recompile Ruby in Cygwin or get a Cygwin Ruby distribution.
(In Windows using RailsInstaller) The only way for me was to do add and alias to the installation path.
alias rails='C:/RailsInstaller/Ruby1.9.3/bin/rails'
Once I typed that within cygwin terminal, it worked just fine.

Rails: Why "sudo" command is not recognized?

In my application directory (on Windows) I run:
sudo pdfkit --install-wkhtmltopdf
as explained here, but I got this error:
'sudo' is not recognized as an internal or external command,
operable program or batch file.
What could be the problem ?
Sudo is a Unix specific command designed to allow a user to carry out administrative tasks with the appropriate permissions.
Windows does not have (need?) this.
Run the command with the sudo removed from the start.
sudo is a Unix/Linux command. It's not available in Windows.
sudo is used for Linux. It looks like you are running this in Windows.
That you are running Windows. Read:
http://en.wikipedia.org/wiki/Sudo
It basically allows you to execute an application with elevated privileges. If you want to achieve a similar effect under Windows, open an administrative prompt and execute your command from there. Under Vista, this is easily done by opening the shortcut while holding Ctrl+Shift at the same time.
That being said, it might very well be possible that your account already has sufficient privileges, depending on how your OS is setup, and the Windows version used.
sudo is a command for Linux so it cant be used in windows so you will get that error
Sudo is a Unix specific command designed to allow a user to carry out administrative tasks with the appropriate permissions.
Windows doesn't not have (need?) this.
Yes, windows don't have sudo on its terminal. Try using pip instead.
Install pip using the steps here.
type pip install [package name] on the terminal. In this case, it may be pdfkit or wkhtmltopdf.
Analogue to sudo in Windows is running command prompt "As Administrator" by right-clicking on it's link. Then everything you run in it will be "sudo-ed".
sudo is not for windows, its for unix/linux.
option 1: install ubuntu cli software (not OS) in windows, here is the windows store link: https://www.microsoft.com/en-in/p/ubuntu-2004/9n6svws3rx71. After installing you can use ubuntu's cli in your windows where sudo will work.
option 2: install and use gem (ruby on rails) for installing wkhtmltopdf-binary
gem install pdfkit
gem install wkhtmltopdf-binary
ref: https://github.com/pdfkit/pdfkit
option 3: you can use npm or python for wkhtmltopdf insted of ruby on rails, both modules (nodeJS python) works fluently and compatible with windows:-
https://www.npmjs.com/package/wkhtmltopdf
https://pypi.org/project/wkhtmltopdf/

Resources