Snap web framework and OSX Path - macos

preface: new to OSX development.
cabal install snap --this works fine.
When I type snap into the terminal nothing happens. How do I export my snap path to my $PATH in OSX?
same thing happens with happstack and yesod.... those are both installed as well

Simply do (in the terminal):
export PATH="$HOME/.cabal/bin:$PATH"
To make it permanent, add that line to the hidden .profile file in your home directory and re-login. You can edit ~/.profile using open ~/.profile. This can also be done with this line in the terminal:
echo 'export PATH="$HOME/.cabal/bin:$PATH"' >> ~/.profile

Related

Laravel Spark Installation in MAC

I'm new to mac and I don't know how to add path to the system. I have already cloned the file for spark and done composer update. I need to this next step. How do I do it in MAC?
Next, make sure the spark-installer directory is added to your systems $PATH variable, so that your machine will be able to locate the spark executable when you issue Spark commands.
You do it by updating the PATH variable.
export PATH=$HOME/.composer/vendor/bin:$PATH
However, this will not persist. If you close the terminal window, the PATH will be restored to its original value. You need to add this line to your ~/.bash_profile
Run this command to add the line to your ~/bash_profile
echo 'export PATH=$HOME/.composer/vendor/bin:$PATH' >> ~/.bash_profile
To verify that you have the correct path: echo $PATH, and you should see .composer/vendor/bin in the middle of the output
For spark specifically, you need to add the path to the location where you cloned the repo.
echo 'export PATH=path/to/spark/repo:$PATH' >> ~/.bash_profile
Here is a full list of commands to install Spark:
cd $HOME
git clone https://github.com/laravel/spark-installer.git
echo 'export PATH=$HOME/spark-installer:$PATH' >> ~/.bash_profile
source ~/.bash_profile
cd ~/spark-installer
composer install
spark

How to set .bash_profile, if it does not exist yet. I want to launch sublime from a command line in Mac

I want to launch sublime from a command line in Mac, using subl filename. It seems to involve dealing with .bash_profile. But I didn't locate the file. What steps to be taken?
A typical install of OS X won't create a .bash_profile for you. When you want to run functions from your command line, this is a must-have.
Start up Terminal
Type cd ~/ to go to your home folder
Type touch .bash_profile to create your new file.
Edit .bash_profile with your favorite editor (or you can just type open -e .bash_profile to open it in TextEdit.
Type . .bash_profile to reload .bash_profile and update any functions you add. Notice the space between the two dots!
Update
I'm on Mac OS Mojave.
Open Terminal.app and paste bellow line,
(1) touch .bash_profile
(2) open -a TextEdit.app .bash_profile
this will open a blank page in TextEdit.app , from here you can add,update,delete code.
I hope this will help someone.
just create a new file - it doesn't come default with your computer. all under your user directory - ex. /Users/username
touch .bash_profile
~/.bash_profile
Q1. How to check if .bash_profile exists or not in my mac?
Solution: If you're using macOS 10.14 (Mojave) or below. Then open the Terminal.app. Run the following command to check if the .bash_profile exists or not in your mac.
if [ -r ~/.bash_profile ];
then
echo "Yes, file exists"
else
echo "No, file does not exists"
fi
After running the above command if you get the following line - "Yes, file exists" printed in your Terminal.app. That means the file exists in your mac.
If you get the following line - "No, file does not exist" printed in your Terminal.app. That means the file does not exist in your mac.
To create a .bash_profile file in your mac. Run the following command,
touch ~/.bash_profile
To restrict access to the .bash_profile. Run the following command,
chmod 700 ~/.bash_profile
Q2. I want to launch sublime from a command line in Mac?
Solution: To launch sublime from mac. You can make a symlink to subl. Assuming you've placed Sublime Text in the Applications folder, and that you have a ~/bin directory in your path, you can run the following command:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
For more details visit the official sublime documentation

How can I edit bash_profile if open command does not work and hidden file does not open in mac

I tried to change something in my bash_profile but I think I mistyped something. So I can not run any terminal commands. If I post "ls" command then I get
-bash: ls: command not found
Now I can not open bash_profile also. So what can I do here. I get the below path using echo command but there was some any other path. Please help.
echo $PATH: /usr/local/bin:/usr/local/bin:
But if I write /bin/ls it works.
MacBook Pro El Capitan : 10.11.4
This is the possible answer - And I solved it using nano editor
You messed up your PATH environment variable.
/bin/ls
works because you did not need PATH to find the 'ls' program. You can run ANY command by specifying its full path.
You need to re-edit your .bash_profile to either remove your PATH, or fix it. I do not know what editor you used to modify .bash_profile to begin with, but you can use
/usr/bin/nano
/usr/bin/vi (ONLY if you know vi/Vim)
/usr/bin/vim (ONLY if you know vi/Vim)
/usr/bin/emacs (I shutter to think about this)
TextWrangler (a very good free GUI text editor)
http://www.barebones.com/products/textwrangler/
Or you can just rename the current .bash_profile and start a new terminal session, then fix the renamed .bash_profile before putting it back in service
/bin/mv .bash_profile saved.bash_profile

Torch / Lua after installation is not working

I have followed the following approach in order to install Torch in my machine (Mac).
http://torch.ch/docs/getting-started.html#_
When I am done with the installation, I type:
$ luarocks install image
or $ luarocks lis
or $th
in order to load the th or to make updates on the lua packages. It says "command not found". Do you have any idea how I can resolve this issue?
If you're on a Mac using the bash terminal, make sure that you've permanently added /Users/you/torch/install/bin to your PATH.
To do this:
Navigate in your terminal to the root directory by running the command:
$ cd
Using the text editor of your choice (emacs, vim, etc.) open the .bash_profile file for editing. For example:
$ emacs .bash_profile
Add the following line to the end of the file (replacing 'you' with your Mac username):
PATH=$PATH\:/Users/you/torch/install/bin ; export PATH
Save and exit the text editor
Source the changes by running:
$ source .bash_profile
Check that your PATH has been updated (look for /Users/you/torch/install/bin in the string returned):
$ echo $PATH
To make sure it has been changed permanently, completely quit Terminal, open it and run echo $PATH again
Now try th and it should run Torch!
For more help on PATH:
https://kb.iu.edu/d/acar
The Torch installation (at least for me) added the line . /Users/jb/torch/install/bin/torch-activate to my .profile file, not .bash_profile. I tried adding that exact line to .bash_profile but it didn't work, so based on the recommendations here I got rid of the trailing directory and such.
Have you updated your PATH? It should include something like
/home/user/torch/install/bin
I faced the same issue and following this post deleted and reinstalled everything. However in the end what helped was adding /home/user/torch/install/bin/ to the PATH variable.
I have resolved the issue. I have deleted torch and I have installed it again. I have updated my PATH, and I have ran the $ luarocks install image command. After all of these, I was able to ran $ th command and in general torch.

How to install Dart to be used in the terminal? (command line)

How do you install Dart so the language can be used within the terminal? (For UNIX based systems, such as a Mac)
After installing Dart (currently located at https://www.dartlang.org/), you will need to do some additional work to use dart commands in the terminal (command line), as it needs to be added to the Bash profile PATHs (on a UNIX based system). To do this, run the following handy command to open the .bash_profile file in it’s default location and with the system’s default text editor touch ~/.bash_profile; open ~/.bash_profile.
Next find the directory that Dart was downloaded to and put the path for dart-sdk/bin inside the .bash_profile as apart of the PATH variable. I.e. a line of code should be added to this file that looks something like this (if you’ve put the dart install in the applications folder on a Mac): export PATH=$PATH:/Applications/Dart/dart-sdk/bin.
To get Bash to start using this new profile immediately without restart, enter source ~/.bash_profile in the terminal (command line), then to double check the PATHs have updated, by enter in the command echo $PATH.
1) Install Dart in your environment (if have not yet)
https://www.dartlang.org/tools/sdk#install
2) Add PATH variable for dart/bin
Example for Ubuntu
# add path example
echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.bashrc
source .bashrc
or it can be .bash_profile instead of .bashrc
3) And now just run your .dart file with the main() method in the terminal and see an output
$ dart path_to_your_file/your_file_with_main.dart

Resources