Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS 10.14.6 #17

Closed
fabern opened this issue Oct 21, 2019 · 15 comments · Fixed by #21
Closed

MacOS 10.14.6 #17

fabern opened this issue Oct 21, 2019 · 15 comments · Fixed by #21

Comments

@fabern
Copy link

fabern commented Oct 21, 2019

Hi Tavinus,

On macOS (10.14.6) I got an error trying to use the install script.

Fabers-MacBook-Pro-2:~ faber$ curl -s -o /tmp/pdfScale.sh 'https://raw.githubusercontent.com/tavinus/pdfScale/master/pdfScale.sh' && bash /tmp/pdfScale.sh --install
readlink: illegal option -- f
usage: readlink [-n] [file ...]
pdfScale.sh v2.4.9 - Self Install

Current location : 
Target location  : /usr/local/bin/pdfscale
cp: : No such file or directory
There was an error when trying to install pdfScale.
Do you want to try again with sudo (as root)? Y/y to continue > Y
cp: : No such file or directory
There was an error when trying to install the program.

Current location is not detected. This is probably linked to trying to use readlink on macOS.
https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac

My workaround to this was by installing
brew install coreutils and then modifying the pdfScale.sh to use greadlink instead of readlink following the answer: https://stackoverflow.com/a/4031502

Best regards,
Fabian

@tavinus
Copy link
Owner

tavinus commented Oct 23, 2019

Thanks for letting me know.
Seems like a portable solution is not that easy.
I am trying to decide what is the best portable way that can be implemented in bash.
Then I will make a new version with it and publish here.

@tavinus
Copy link
Owner

tavinus commented Mar 31, 2020

This problem is so stupid and so annoying.

I have a working portable solution for realpath, but I am still struggling to have a portable GNU readlink -f solution.

The BSD readlink could be OK, since the non canonicalized version of the path should be ok to install. But then it does not work for the current folder (./ or no folder reference). Which is beyond stupid and I really can't understand why on earth it would behave like this.

It is 2020 and this is still a big problem for many scripts.

@tavinus
Copy link
Owner

tavinus commented Apr 3, 2020

Branch v2.5 is being tested and should fix this.

https://github.com/tavinus/pdfScale/tree/v2.5

The Installer and the Upgrader should now work on MacOSX (can you please test them for me?)

Please note that the Upgrader will end up failing because it will download the old version from the master branch (for now). But if the installer of the new version works, the upgrader will also work after merging it to the master branch.

EDIT
v2.5.2 fixes a problem with curl redirects that was breaking upgrades.

@fabern
Copy link
Author

fabern commented Apr 4, 2020

Thanks for checking the issue. Installation says successful, but afterwards permission denied when trying to use the program. I'm installing not from master but from the branch v2.5.

bernharf@bernstein:~|⇒  curl -s -o /tmp/pdfScale.sh 'https://raw.githubusercontent.com/tavinus/pdfScale/v2.5/pdfScale.sh' && bash /tmp/pdfScale.sh --install
pdfScale.sh v2.5.2 - Self Install

Current location : /tmp/pdfScale.sh
Target location  : /usr/local/bin/pdfscale
cp: /usr/local/bin/pdfscale: Permission denied
There was an error when trying to install pdfScale.
Do you want to try again with sudo (as root)? Y/y to continue > Y
Password:

Success! Program installed!
 > /usr/local/bin/pdfscale

But using doesn't work:

bernharf@bernstein:~|⇒  /usr/local/bin/pdfscale
zsh: permission denied: /usr/local/bin/pdfscale

bernharf@bernstein:~|⇒  ls -thal /usr/local/bin/pdfscale
-rw-r--r--  1 root  admin    92K Apr  4 15:11 /usr/local/bin/pdfscale

@fabern
Copy link
Author

fabern commented Apr 4, 2020

Modifying user rights to have it executable doesn't change anything for my user:

bernharf@bernstein:~|⇒  sudo chmod u+rwx /usr/local/bin/pdfscale
Password:
bernharf@bernstein:~|⇒  ls -thal /usr/local/bin/pdfscale
-rwxr--r--  1 root  admin    92K Apr  4 15:11 /usr/local/bin/pdfscale
bernharf@bernstein:~|⇒  /usr/local/bin/pdfscale -p
zsh: permission denied: /usr/local/bin/pdfscale

However, when sudoing the last command then I successfully get a list of the formats.

@fabern
Copy link
Author

fabern commented Apr 4, 2020

Regarding the Upgrader. It seems to work when using sudo:

bernharf@bernstein:~|⇒  sudo pdfscale --upgrade
pdfscale v2.5.2 - Self Upgrade

Preparing download to temp folder
 > /tmp/pdfScale_20200404-153717.tar.gz
Downloading file with curl

Extracting compressed file

   Current Version is: 2.5.2
Downloaded Version is: 2.4.9

Seems like the downloaded version is older that the one installed.
It is basically a miracle or you have came from the future with this version!
BE CAREFUL NOT TO DELETE THE BETA/ALPHA VERSION WITH THIS UPDATE!

Are you sure that you want to replace the current installation with the downloaded one?
Y/y to continue, anything else to cancel > n

Exiting...  (cancelled by user)

Cleaning up downloaded files from /tmp
 > /tmp/pdfScale_20200404-153717.tar.gz > Ok
 > /tmp/pdfScale-master > Ok

@tavinus
Copy link
Owner

tavinus commented Apr 4, 2020

That is rather weird.
When I tested here (was on Yosemite) it didn't even ask for sudo and I could just call pdfscale without the full path.

Since /usr/local is not a "normal" BSD/Mac folder, it is only created after homebrew is installed (so the permissions may vary).

The weirdest part is it being able to install but not setting the proper execution permissions. Even more weird is that you could not apply the execution flag manually.

What happens if you just

sudo chmod +x /usr/local/bin/pdfscale
/usr/local/bin/pdfscale -p

I wonder if zsh is doing something weird.
Can you also try from bash?

Both the upgrader and the installer should ask for sudo automatically if needed. Meaning that you should be able to just run without sudo and it will ask for it if needed. No harm on calling it with sudo from the start though, it should just install as root in that case (but set execution to everyone).

@tavinus
Copy link
Owner

tavinus commented Apr 4, 2020

Usually the permissions of files is maintained on copies, but it seems like this is not the case here.

What happens is that we download the new version, set it to executable and run it. Then it will copy itself to the desired location (and here it should maintain the execution flag, but it is not doing that).

I will add a chmod call after the install to reapply the execution flag and then we can see if it solves the issue.

Will push it in a few minutes

@tavinus
Copy link
Owner

tavinus commented Apr 4, 2020

Ok, new version (v2.5.3) is there. Can you test it please?

curl -s -o /tmp/pdfScale.sh 'https://raw.githubusercontent.com/tavinus/pdfScale/v2.5/pdfScale.sh' && bash /tmp/pdfScale.sh --install

Then

/usr/local/bin/pdfscale --upgrade

NOTE You can change the installation path if you want, just pass it to the installer as a parameter

pdfscale --install /my/custom/path

The upgrader will install in place (will keep current location, whatever it is).

@fabern
Copy link
Author

fabern commented Apr 4, 2020

Executing sudo chmod +x /usr/local/bin/pdfscale fixed the existing installation v2.5.2. Resulting in an executable, workgin file. Essentially it moved the rights from -rwxr--r--to -rwxr-xr-x.

I have not tried on bash.

v2.5.3 installs but with a short hiccup, requesting root access for installation:

bernharf@bernstein:~/switchdrive/Documents/Job/Anstellung 2019 WSL/Doktorat/Literature/Library/Kirchner-2019-Hydrol. Earth Syst. Sci.|
⇒  curl -s -o /tmp/pdfScale.sh 'https://raw.githubusercontent.com/tavinus/pdfScale/v2.5/pdfScale.sh' && bash /tmp/pdfScale.sh --install

pdfScale.sh v2.5.3 - Self Install

Current location : /tmp/pdfScale.sh
Target location  : /usr/local/bin/pdfscale

The target file already exists: /usr/local/bin/pdfscale
Y/y to overwrite, anything else to cancel > y
Target will be replaced!
cp: /usr/local/bin/pdfscale: Permission denied
There was an error when trying to install pdfScale.
Do you want to try again with sudo (as root)? Y/y to continue > y

Success! Program installed!
 > /usr/local/bin/pdfscale
bernharf@bernstein:~|⇒  pdfscale -p
pdfscale v2.5.3

@fabern
Copy link
Author

fabern commented Apr 4, 2020

It might be that my install is somewhat non-standard. I'm using brew but don't master all the intricacies of access rights.

On another computer - the one from my initial post in October – update to v2.5.3 works without an issue. On that computer access rights of /usr/local/bin/pdfscale were already on -rwxr-xr-x.

@tavinus
Copy link
Owner

tavinus commented Apr 4, 2020

Cool. Seems solved then.

The difficult part is always finding a solution that is portable and works everywhere.

I think that your chmod call ( chmod u+rwx ) was setting it executable only for root (which is the owner of the file).

chmod +x sets it executable on all levels (user-group-everyone), which is the default for system-wide apps.

@fabern
Copy link
Author

fabern commented Apr 4, 2020

I just noticed that the two computers differ in their output to ls -thal /usr/local/bin/pdfscale.

While the computer where it works shows:
-rwxr-xr-x 1 [username] admin,
the one with the difficulties showed
-rwxr-xr-x 1 root admin
i.e. root instead of [username].

@fabern
Copy link
Author

fabern commented Apr 4, 2020

So on one computer the owner was root while on the other it was the active user...

Okay, probably due to some mistake of mine. ^^
Thanks for your time and efforts!

@tavinus
Copy link
Owner

tavinus commented Apr 4, 2020

There is no problem that the ownership is different (or root), as long as it is executable to everyone.

Usually it is owned by root with permissions to be executed by others (when system installed).

@fabern fabern closed this as completed Apr 4, 2020
@tavinus tavinus mentioned this issue Apr 5, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants