Compiling fails due to space in path to home folder

 
Thread Tools Search this Thread
Operating Systems OS X (Apple) Compiling fails due to space in path to home folder
# 1  
Old 01-31-2012
Compiling fails due to space in path to home folder

I seem to have issues compiling software and I think I've narrowed it down to something having to do with having a space in the path name to my Home folder (which contains "Macintosh HD"). The reason I think this is shown here:

Code:
[/]$ echo $HOME
/Volumes/Macintosh HD/Users/Tom
[/]$ cd $HOME
-sh: cd: /Volumes/Macintosh: No such file or directory
[/]$ cd /Volumes/Macintosh\ HD/Users/Tom
[/Volumes/Macintosh HD/Users/Tom]$

In other words simply changing directory to my Home folder using the environment variable $HOME fails, but when escaping the space in "Macintosh HD" it seems to work. One weird thing, however, is that the "~" shortcut seems to work fine, i.e.

Code:
[/]$ echo ~
/Volumes/Macintosh HD/Users/Tom
[/]$ cd ~
[/Volumes/Macintosh HD/Users/Tom]$

so I'm not entirely sure if the space is a problem. Are $HOME and "~" handled the same way?

Most importantly, does anyone have a workaround for this? I'd rather not change my home directory to something without a space because doing this causes several things to break apparently, including stopping me from being able to log in to my computer.

Any thoughts or solutions would be helpful.

Thanks,
Tom
# 2  
Old 01-31-2012
Variables split on spaces unless you tell them not to. You do so with double-quotes. cd "$HOME" for instance ought to work.

As for ~, yes, that won't split. It's because of the way expansion happens in the shell -- it'd have to do two substitutions to split ~ into two strings, but $HOME while unquoted splits by design.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 01-31-2012
I thought it might have something to do with that so I tried quoting it with the same results, however I used single quotes instead of double so maybe that caused it to fail.

Is there any way to get around this without quoting the variable? The problem is when compiling software, which must be using unquoted environment variables. Is there anyway to use a symlink or something along those lines?
# 4  
Old 02-01-2012
Quote:
Originally Posted by tdgrant1
I thought it might have something to do with that so I tried quoting it with the same results, however I used single quotes instead of double so maybe that caused it to fail.
Nothing expands inside single quotes.
Quote:
Is there any way to get around this without quoting the variable?
No.
Quote:
The problem is when compiling software, which must be using unquoted environment variables.
Why must they be unquoted? The quotes go away -- they don't bother the program they're being fed into.

Why not show exactly what you're doing, and exactly what the problem is?

A symlink might work, if you have sufficient permissions to make it.
Code:
ln -s "/path/to/long name" "/path/to/shortname"

# 5  
Old 02-01-2012
Quote:
Why must they be unquoted?
I don't mean to say they must be unquoted in the sense that it's a rule, I mean that the programs that I'm trying to compile (not written by me) seem to be using unquoted variables, causing $HOME to be split.
Quote:
Why not show exactly what you're doing, and exactly what the problem is?
This seems to be a common problem with many different programs from different authors, but, for example, I was attempting to install the program FFTW (a fourier transform library). Here's what I did (following the install instructions):
Code:
[fftw-3.3]$ ./configure
...lots of code with no errors...
[fftw-3.3]$ make
...lots of compile code...
./libtool: line 3168: cd: /Volumes/Macintosh: No such file or directory
...a few more lines of code...
make[2]: *** [libfftw3.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
[fftw-3.3]$

Again, this is just an example and similar output is seen for multiple programs.

I'm not quite sure how I would use the symlink though. Would it be something as simple as
Code:
ln -s "/Volumes/Macintosh" "/Volumes/Macintosh HD/"

I don't know what would happen if the program is simply using $HOME as the start of the path to another directory. In other words, assuming the above symlink is in place, if I type
Code:
cd $HOME

the computer sees
Code:
cd /Volumes/Macintosh

which with the above symlink should be read as
Code:
cd /Volumes/Macintosh HD/

correct?

However if I type
Code:
cd $HOME/path/to/directory/

would the computer see
Code:
cd /Volumes/Macintosh/path/to/directory/

(not what I want)
or
Code:
cd /Volumes/Macintosh HD/path/to/directory/

(what I want)

Thanks for all your help!
# 6  
Old 02-01-2012
Quote:
Originally Posted by tdgrant1
I don't mean to say they must be unquoted in the sense that it's a rule, I mean that the programs that I'm trying to compile (not written by me) seem to be using unquoted variables, causing $HOME to be split.
I see.

Quote:
I'm not quite sure how I would use the symlink though. Would it be something as simple as
Code:
ln -s "/Volumes/Macintosh" "/Volumes/Macintosh HD/"

You've got it exactly backwards. I showed you an example... Imagine how the cp command works -- the first parameter is the original, the second is the thing being created. This took me a while to get my head around too.

Quote:
I don't know what would happen if the program is simply using $HOME as the start of the path to another directory.
I doubt it uses $HOME -- why would it assume the source code is in $HOME? -- but the current directory, whatever that may be. If your current directory is the symlink, not the long path, I think that should work -- cd-ing into /home/shortname/whatever will get you the contents of /home/long name/whatever without the spaces in the name.

Quote:
In other words, assuming the above symlink is in place, if I type
Code:
cd $HOME

the computer sees
Code:
cd /Volumes/Macintosh

which with the above symlink should be read as
Code:
cd /Volumes/Macintosh HD/

correct?
Just creating a symlink doesn't mean it'll use it. cd $HOME will still go to the long path. Don't bother messing with the value of $HOME, either -- that could have bad side-effects.

The symlink acts like a folder. cd /home/shortname will change directory into /home/shortname, not /home/long name, even though you're looking at the folder contents of /home/long name. Only the kernel really cares, so if the symlink's valid it works.

Just cd /home/shortname/whatever/, re-configure, and re-compile from there.

---------- Post updated at 10:15 AM ---------- Previous update was at 10:12 AM ----------

Another thing you could do is ignore your home folder, just build it in /tmp.

Code:
mkdir /tmp/build
cd /tmp/build
tar -zxf /path/to/source-code.tar.gz
./configure
make

This User Gave Thanks to Corona688 For This Post:
# 7  
Old 02-01-2012
Quote:
why would it assume the source code is in $HOME? -- but the current directory
I think this may be the issue here. I was assuming that it was using $HOME but you're indeed right that it's just using the current directory, which happens to also be in $HOME, so the problem still arises. Luckily I have recently replaced my optical drive with a shiny new solid state drive which I run my system off of (home folder remains in the old HD) and so I just moved my installation to my SSD. Doing this removes the issue with the space and sure enough, everything is installing correctly.

Thanks for your help with this!
This User Gave Thanks to tdgrant1 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh fails due to argument position.

I have a constraint to follow organization policy. So i do not have much liberty. ssh -i /opt/nonprod user1@hostone -t bash works while ssh -i /opt/nonprod -t bash user1@hostone fails How can I get this to work when I am enforced to put -t bash before the user@hostname ? Will share debug... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Move files from Space Folder to other folder

I want to move a folder with spaces from one folder to another. I have two folders like this, 1).RT_032-222 -4444-01/ 2). RT_032-555 -7777-01/ I want to move files from 2 to 1 through shell script.Here I want to assign this like a user defined variable like as Source branch... (2 Replies)
Discussion started by: kannansoft1985
2 Replies

3. BSD

Compiling BOINC/Seti@Home for OpenBSD 5.3 Sparc64

I used to use x86 Linux clients for this years ago, but ceased all activity until last night. I have resurrected an old Sun Blade 100, which used to run Solaris 9, when I first owned it, in the 2003 period, but now is very much alive with 2 gig of new ram, and and extra 10 gig of drive space... (0 Replies)
Discussion started by: RichardET
0 Replies

4. Shell Programming and Scripting

Record length check fails due to '\' character

When I check the length for the records in the file, it does not give me the correct value. I used wc -l command. Example records: abcdefghij abcd\efghij abcdefghi Expected output is: 10 11 9 But the output returned is 10 10 9 Please help me on this issue. (10 Replies)
Discussion started by: Amrutha24
10 Replies

5. UNIX for Dummies Questions & Answers

Find command fails when a space is in the directory path variable

I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use. #!/bin/bash CFS=$IFS IFS=$(echo) set dir = "/Users/apta/Library/Mail\... (3 Replies)
Discussion started by: apta
3 Replies

6. Red Hat

Unable to free space due to inode in use by database

Hi, I am having similar issue showing filesystem 100% even after deleting the files. I understood the issue after going through this chain. But i can not restart the processes being oracle database. Is there way like mounting filesytem with specific options would avoid happening this issue. How... (0 Replies)
Discussion started by: prashant185
0 Replies

7. UNIX for Dummies Questions & Answers

Compiling DigSig fails: Compiler/Makefile output

Hey, I'm trying to install DigSig ( disec.sourceforge.net ) on my CentOS5 distro. I was following all the steps in the readme but it didn't work. So here's the output: # ./digsig.init compile make: Entering directory `/usr/src/kernels/2.6.18-194.32.1.el5-i686' CC ... (2 Replies)
Discussion started by: disaster
2 Replies

8. Shell Programming and Scripting

Compiling all modified Java files in a folder on Unix

Hi all, I have a Unix script that will compile all Java files in a sub folder as follows: find . -name "*.java" -print -exec $JAVA_HOME/bin/javac -cp .:$CLASSPATH '{}' \; I would like to enhance it to only compile those Java files who: 1.) Have no class file 2.) Have a class file... (1 Reply)
Discussion started by: Annorax
1 Replies

9. Windows & DOS: Issues & Discussions

How can I upload a zip folder on a unix path from my windows folder?

Hello, I am an amature at UNIX commands and functionality. Please could you all assist me by replying to my below mentioned querry : How can I upload a zip folder on a unix path from my windows folder? Thanks guys Cheers (2 Replies)
Discussion started by: ajit.yadav83
2 Replies

10. SCO

Unable to dump due to limited space?

After rebuilding the RAIDs on the SCO Unix, the following dialog appears when rebooting the machine. Fssat: /dev/boot mounted Mounted /stand filesystem Fsstat: /dev/usr1 okay Mounted /usr1 filesystem (continues usr2, usr3, Fsstat: /dev/usr4 okay Panic: HTFS: Bad directory ino... (2 Replies)
Discussion started by: Mac Tire
2 Replies
Login or Register to Ask a Question