holzschu / a-shell

A terminal for iOS, with multiple windows
BSD 3-Clause "New" or "Revised" License
2.72k stars 117 forks source link

Cannot install packages #607

Open zanodor opened 1 year ago

zanodor commented 1 year ago

This is the error I'm getting:

/private/var/containers/.../a-Shell-mini.app/bin/pkg: 58: curl: not found

Same in the bigger A-Shell.

I was trying to install git (and want to try out GH as well).

Any ideas?

Cheers

holzschu commented 1 year ago

What command did you type? curl is already installed in both apps, so this is strange.

zanodor commented 1 year ago

Any command: pkg install git

zanodor commented 1 year ago

I think the issue might come from text garbled "underneath".

How do I reset without reinstall?

Although to have the same issue in a just-installed A-Shell is strange...

Is it the fact maybe that I'm jailbroken?

zanodor commented 1 year ago

By garbled text I meant:

https://share.icloud.com/photos/01cj68RNF6T1hyC7H30jNWhwg

holzschu commented 1 year ago

To answer the easy question: Control + L should clear the screen (there's also the command "clear").

Now for the difficult question. The interesting bit and a likely clue is the "dircolors: command not found" before each line. Nothing in a-Shell is calling "dircolors" to the best of my knowledge. You mentionned that the device is jailbroken. Which probably means there is a "sh" somewhere in the PATH. Since pkg is a shell script, a-Shell is probably trying to execute it using the system sh, rather than our own. But that sh does not see the command curl.

To test this hypothesis: type sh --version and see what it says. If it says GNU bash..., you are using the system sh, not a-Shell's sh. In that case, copy a-Shell's version of pkg in your ~/Documents/bin directory (create it if needed), then edit it and replace the top line with #! dash, then try again.

zanodor commented 1 year ago

Thanks for your response.
I'm a bit surprised – am I your first jailbroken user?

More garbage on trying to give the commands:

[~TUDASTAR]$ sh --version
dash: 0: Illegal option --
[~TUDASTAR]$ sh
dircolors: command not found
\h:\w \u$ 
\h:\w \u$ 

After this, I cleared, exited and after relaunch, I pressed some enters to regain the normal prompt.
Afterwards, I didn't touch it. If I can continue to use lg2, I'll count my blessings and weasel away from anything else.

It does indeed looks like Jailbreak is interfering...?
Of course, with jailbreak I have another terminal I can use but your wonderful app has shortcut support.

holzschu commented 1 year ago

I think you're the first jailbroken user to actually engage a discussion, yes.

I think I'm starting to see the issue. Can you check the content of /etc/profile? (it's the global configuration file, and from the source of dash it is loaded before the user .profile). Also, I gave you the wrong command to test. Can you try ls -l /bin/sh?

I'd also like to compare the result of echo $PATH from inside a-Shell standard shell, and after you typed dash.

With your help, it should be possible to fix this issue. Of course, I'm never going to be able to say in the release notes "now works with jailbroken devices", so it will probably be "various bug fixes"...

zanodor commented 1 year ago

Okay, but you need to bear with me buddy, because I'm not a tech mage. I see profile (file) and a profile.d (folder).

Contents of file 'profile':

export PATH='/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/local/bin:/usr/sbin:/usr/sbin:/usr/bin:/usr/bin:/sbin:/sbin:/bin:/bin:/usr/bin/X11:/usr/bin/X11:/usr/games:/usr/games'
export TMPDIR='/tmp'
export PS1='\h:\w \u\$ '
umask 022

export EDITOR=/usr/bin/editor
export PAGER=/usr/bin/pager

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done

Contents of the profile.d folder:

cacerts.bootstrap.sh
coreutils.sh
gawk.csh
gawk.sh
terminal.sh

Ls -l /bin/sh

[~/Documents]$ 
[~/Documents]$ ls -l /bin/sh
lrwxr-xr-x  1 root  wheel  13 Apr  4 18:41 /bin/sh -> /usr/bin/dash
[~/Documents]$ 

Echo $PATH

[~/Documents]$ 
[~/Documents]$ echo $PATH
/private/var/containers/Bundle/Application/C687755F-0101-456C-8976-A4312C85DC88/a-Shell-mini.ap
p/bin:/private/var/containers/Bundle/Application/C687755F-0101-456C-8976-A4312C85DC88/a-Shell-m
ini.app/Library/bin:/private/var/containers/Bundle/Application/C687755F-0101-456C-8976-A4312C85
DC88/a-Shell-mini.app/Library/bin3:/var/mobile/Containers/Data/Application/02D79BB1-4504-4FA5-A
3A2-CF9DF0862A67/Library/bin:/var/mobile/Containers/Data/Application/02D79BB1-4504-4FA5-A3A2-CF
9DF0862A67/Documents/bin:/usr/bin:/bin:/usr/sbin:/sbin
[~/Documents]$ 

Dash

[~/Documents]$ 
[~/Documents]$ dash
dircolors: command not found
\h:\w \u$ 

I hope I've done well and it all makes sense to you.

Z.

holzschu commented 1 year ago

Thanks a lot, yes, that makes a lot of sense. Your problems come from the fact that there is an /etc/profile file that redefines $PATH, hence the usual commands are not found. It only applies inside dash or for commands that are shell scripts like pkg.

That is not a problem on a non-jailbroken device, because /etc/profile cannot be read by a standard user.

I'll need to disable loading the /etc/profile file in dash. In the meantime, I think you can make it work by creating a .profile file in ~/Documents/, with the following lines (not tested, it might need a bit of tweaking):

export PATH=$APPDIR/bin:$APPDIR/Library/bin:$APPDIR/Library/bin3:$HOME/Library/bin:$HOME/Documents/bin:$PATH
export TMPDIR='~/tmp'
export EDITOR=vim
export PAGER=less

I think that should be good for the commands. There is still the issue of PS1 and dircolors, but that's for a second step.

zanodor commented 1 year ago

I see. Just shoot me a line if you need anything...beer, pizza, the sports paper. As far as I'm concerned, I'm kind of done wanting to tinker around. So I'm okay to wait around for your update (whenever you see fit). I'm guessing you'd update both your packages (I keep the bigger one around just in case, but I'm using the smaller one).

holzschu commented 1 year ago

The latest TestFlight issue removes the loading of /etc/profile, so pkg should now work on jailbroken devices: https://testflight.apple.com/join/REdHww5C

We may encounter other issues further down.

zanodor commented 1 year ago

The latest TestFlight issue removes the loading of /etc/profile, so pkg should now work on jailbroken devices: https://testflight.apple.com/join/REdHww5C

We may encounter other issues further down.

I tried your suggestion and put in your 'profile', but then I was facing the dircolors issue.

TheMetaphysicalCrook commented 1 year ago

The latest TestFlight issue removes the loading of /etc/profile, so pkg should now work on jailbroken devices: https://testflight.apple.com/join/REdHww5C We may encounter other issues further down.

I tried your suggestion and put in your 'profile', but then I was facing the dircolors issue.

  • Remark to other users: Most jailbreaks are temporary jailbreaks, so if anyone (is techie enough and) wants to install packages not included in your app already, they can go ahead and restart iOS + install pkg + rejailbreak again (5 mins' job in all).

@zanodor Hey, I didn't know jailbreaks were temporary.. can you point me in the right direction to read up on / perform such a jailbreak? Thx.

zanodor commented 1 year ago

@TheMetaphysicalCrook

The newer ones are temporary because you lose JB upon restart of iOS.
I don't know about your device, but I used palera1n:
https://ios.cfw.guide/get-started/

If your device is eligible, you can use this ISO with Ventoy:
https://github.com/palera1n/palen1x

A re-jailbreak takes about 2-3 minutes.