Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
Hey everyone,

I've been trying to work on an app for Android on my mac and I was using a tool inside the Android SDK called draw9patch, which lets me determine how an image will be stretched. I got it working before, but I must have done something wrong recently because my terminal won't let me run the file anymore. When I click on the draw9patch file, this is what the terminal comes up with:

Last login: Mon Dec 20 12:57:40 on ttys000
/android-sdk-mac_86/tools/draw9patch ; exit;
BURTSON:~ theburt00$ /android-sdk-mac_86/tools/draw9patch ; exit;
/android-sdk-mac_86/tools/draw9patch: line 30: dirname: command not found
/android-sdk-mac_86/tools/draw9patch: line 33: basename: command not found
/android-sdk-mac_86/tools/draw9patch: line 40: dirname: command not found
/android-sdk-mac_86/tools/draw9patch: line 41: dirname: command not found
/android-sdk-mac_86/tools/draw9patch: line 45: dirname: command not found
/android-sdk-mac_86/tools/draw9patch: line 46: dirname: command not found
/android-sdk-mac_86/tools/draw9patch: line 50: basename: command not found
: can't find draw9patch.jar
logout

[Process completed]

By the way, I placed the Android SDK folder at the root of my hard drive.

Does anyone know what the problem is? Thanks in advance!
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
What do you get from the following in Terminal:

Code:
echo $SHELL; echo $PATH; which dirname basename
 
Last edited:

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
What do you get from the following in Terminal:

Code:
echo $SHELL; echo $PATH; which dirname basename

Here it is:

Code:
Last login: Mon Dec 20 13:13:46 on ttys000
BURTSON:~ theburt00$ echo $SHELL; echo $PATH; which dirname basename
/bin/bash
{PATH}:/Users/theburt00/Documents/android-sdk-mac_86/tools
-bash: which: command not found
BURTSON:~ theburt00$

Ah, I think the problem is because I've tried to run it in different locations. Looks like its referring to a file I put in Documents that I have since deleted.

Do you know what I should do next? Thanks!
 

talmy

macrumors 601
Oct 26, 2009
4,726
332
Oregon
Your path looks messed up. That's why it can't find anything but shell commands. Probably a problem in your .profile file. You can temporarily restore sanity with:

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

You probably want the statement:

export PATH="/Users/theburt00/Documents/android-sdk-mac_86/tools:$PATH"

in your .profile.
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
Your path looks messed up. That's why it can't find anything but shell commands. Probably a problem in your .profile file. You can temporarily restore sanity with:

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

You probably want the statement:

export PATH="/Users/theburt00/Documents/android-sdk-mac_86/tools:$PATH"

in your .profile.

What should I put in the terminal? Do I have to access the .profile somehow first? I'm new to the terminal, so I don't know what to do. The file I'm trying to open is under /android-sdk-mac_86/tools/draw9patch
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
First let's get the PATH variable fixed, as Talmy suggested. In Terminal, enter

Code:
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

See if draw9patch then works as it did before.

In any case, let's also see what your .profile looks like. In Terminal, please enter

Code:
cat ~/.profile

and post the result.
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
draw9patch still doesn't work.

here's the latest output:

Code:
Last login: Mon Dec 20 18:39:53 on ttys000
BURTSON:~ theburt00$ cat ~/.profile
-bash: cat: command not found
BURTSON:~ theburt00$
 

chown33

Moderator
Staff member
Aug 9, 2009
10,731
8,407
A sea of green
Your PATH is damaged, so what you tried can't work. An undamaged PATH is needed to find commands, including the 'cat' command. That's why the first instruction you were told to do was:
In Terminal, enter
Code:
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
If you did the above once, it only lasted until the Terminal window closed. If you didn't do the above at all, then you need to be more careful about following instructions.

Until after you've fixed your .profile, you will need to paste this command into your Terminal window every time you start Terminal or open a new Terminal window:
Code:
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

I suggest copying and pasting the above command into a plain text file in TextEdit.app. You can then copy and paste it into Terminal windows as needed. And until you get your .profile fixed, you will probably need it more than once.
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
ok i think im getting closer. i put that command in the terminal and then tried to open draw9patch. it caused the terminal to output something i havent seen before, but it still hasn't opened draw9patch. am i doing the right thing to open it? also, do you know a way i can fix my damaged path? thanks

Code:
 Last login: Tue Dec 21 14:13:28 on ttys000
BURTSON:~ theburt00$ export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
BURTSON:~ theburt00$ /android-sdk-mac_86/tools/draw9patch
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jdesktop/swingworker/SwingWorker
	at com.android.draw9patch.Application$1.run(Application.java:48)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.ClassNotFoundException: org.jdesktop.swingworker.SwingWorker
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	... 9 more
BURTSON:~ theburt00$
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
yay! the swing-worker.jar file fixed the problem. i put this in the terminal and it launched draw9patch:

Code:
Last login: Tue Dec 21 17:44:27 on ttys000
BURTSON:~ theburt00$ export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
BURTSON:~ theburt00$ /android-sdk-mac_86/tools/draw9patch

looks like i still need to fix the PATH, but at least its working! let me know if i can fix the PATH as well, but otherwise, thanks for the help!
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
yay! the swing-worker.jar file fixed the problem. i put this in the terminal and it launched draw9patch:

Code:
Last login: Tue Dec 21 17:44:27 on ttys000
BURTSON:~ theburt00$ export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
BURTSON:~ theburt00$ /android-sdk-mac_86/tools/draw9patch

looks like i still need to fix the PATH, but at least its working! let me know if i can fix the PATH as well, but otherwise, thanks for the help!

Glad to help. Fixing the PATH environment variable should not be difficult. In Terminal, enter

Code:
/bin/cat  ~/.profile

and post what you get.
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
ok, here it is:

Code:
Last login: Wed Dec 22 18:04:28 on ttys000
BURTSON:~ theburt00$ /bin/cat  ~/.profile
cat: /Users/theburt00/.profile: No such file or directory
BURTSON:~ theburt00$
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
ok, here it is:

Code:
Last login: Wed Dec 22 18:04:28 on ttys000
BURTSON:~ theburt00$ /bin/cat  ~/.profile
cat: /Users/theburt00/.profile: No such file or directory
BURTSON:~ theburt00$

OK, no .profile file. What do you get from

Code:
/bin/cat  ~/.bashrc

in Terminal?
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
i get the same thing. i remember putting these commands in before, and i think at the time i was reading something that told me to clear it.

Code:
Last login: Wed Dec 22 18:04:55 on ttys000
BURTSON:~ theburt00$ /bin/cat  ~/.bashrc
cat: /Users/theburt00/.bashrc: No such file or directory
BURTSON:~ theburt00$
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
i get the same thing. i remember putting these commands in before, and i think at the time i was reading something that told me to clear it.

Code:
Last login: Wed Dec 22 18:04:55 on ttys000
BURTSON:~ theburt00$ /bin/cat  ~/.bashrc
cat: /Users/theburt00/.bashrc: No such file or directory
BURTSON:~ theburt00$

So where is the PATH variable being set?

What about

Code:
/bin/cat  ~/.login

in Terminal?
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
Aah! Same thing again!

Code:
Last login: Sun Dec 26 16:16:16 on console
BURTSON:~ theburt00$ /bin/cat ~/.login
cat: /Users/theburt00/.login: No such file or directory
BURTSON:~ theburt00$
 

aburtson

macrumors newbie
Original poster
Dec 20, 2010
11
0
Alrighty.

Code:
Last login: Mon Dec 27 14:41:01 on console
BURTSON:~ theburt00$ /bin/cat ~/.bash_profile
export PATH={PATH}:/Users/theburt00/Documents/android-sdk-mac_86/tools

BURTSON:~ theburt00$
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
Alrighty.

Code:
Last login: Mon Dec 27 14:41:01 on console
BURTSON:~ theburt00$ /bin/cat ~/.bash_profile
export PATH={PATH}:/Users/theburt00/Documents/android-sdk-mac_86/tools

BURTSON:~ theburt00$

That's the source of the problem! That line should be

Code:
export PATH=$PATH:/android-sdk-mac_86/tools

(assuming that the android-sdk-mac_86 folder is still in the root directory of your filesystem).

To fix, copy and paste the following into Terminal and press return.

Code:
rm ~/.bash_profile; touch ~/.bash_profile; echo 'export PATH=$PATH:/android-sdk-mac_86/tools' >> ~/.bash_profile

To test, quit and restart Terminal. Then enter

Code:
cat ~/.bash_profile

The command should now work, and you should get

Code:
export PATH=$PATH:/android-sdk-mac_86/tools

You should also be able to launch draw9patch by simply entering

Code:
draw9patch

in Terminal.
 
Last edited:

Droide

macrumors newbie
Apr 19, 2013
1
0
I'm very confused about PATH and things like that...

I have seen videos and GNU manuals about it but even the tutorials for amateurs are very difficult to understand in my opinion. Is there a .profile and PATH tutorial that spells out everything one needs to know to use it?
anyway, here is my contribution:
I was having issues with the .profile file in my mac, I was export -ing the PATHS correctly, but file acted like it didn't existed. I deleted that and bash_profile and build new ones, but nothing worked. Then I tried echo $PATH and I could see that one of the PATHS was incorrect. After that I found that I had Macports whatever that is, and somehow that was making trouble. Then I did an ls -alf and I saw that I had many files that normally contain the PATHS: .profile, profile, bash_profile, .bash_profile, .bash_profile.macports-saved-blah blah... anyway I thought I just had too many and I deleted profile (with no period at beginning) and left .profile also deleted bash_profile and that seemed to work!

Almost 4 hours for this... there is no reason this should be such an issue, where can we find more info about PATH issues?
 

pitaya

macrumors member
Jun 17, 2012
34
0
Hi droide. It's nice that you're interested in learning more about your shell. Maybe this will help a little.

I have seen videos and GNU manuals about it but even the tutorials for amateurs are very difficult to understand in my opinion. Is there a .profile and PATH tutorial that spells out everything one needs to know to use it?

You're missing some basics about how your shell (bash) works, and you need to learn a little bit of related vocabulary. Rather than a "PATH tutorial," what you really need to look for are answers to questions like:

What's an environment variable?
What does it mean to export an environment variable?
In what order does bash read its start up files? What files are read?
Are different files read when bash is started as a login shell rather than a non-login shell?

I saw that I had many files that normally contain the PATHS: .profile, profile, bash_profile, .bash_profile, .bash_profile.macports-saved-blah blah... anyway I thought I just had too many and I deleted profile (with no period at beginning) and left .profile also deleted bash_profile and that seemed to work!

On invocation, does bash read $HOME/profile or $HOME/bash_profile?

It may seem daunting, but you should be able to answer those questions well enough by searching though the bash man page.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,731
8,407
A sea of green
I'm having the same problem- can anyone shed some light? Would greatly appreciate it!
Which problem?

The original problem was a PATH problem, caused by a defective profile file. The second problem was a Java problem.

Post the complete text of the error message you get in the Terminal window. Copy and paste it; don't retype it or paraphrase it. Acuracty is inpormtant.


The fix for the original problem was to find the specific defective profile file, and then correct that file. The steps for accomplishing this are given above. If you haven't done any of those steps, then start there. If you have done those steps, then copy and paste the complete output of this command:
Code:
/bin/ls -la ~
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.