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

[Bug] Scoop shim (sh script) with CRLF end of line since recent scoop update #4616

Closed
Sebourg opened this issue Dec 31, 2021 · 14 comments
Closed
Labels

Comments

@Sebourg
Copy link

Sebourg commented Dec 31, 2021

Bug Report

Since the beginning of the week (approximately), after updating scoop, the %Scoop%/shims/scoop sh script file is not properly formatted.
The script contains CRLF instead of LF end of lines, as result it can not run from cygwin bash.

Current Behavior

After scoop update "*"
Running scoop sh script ($Scoop/shims/scoop) systematically returns an error

$ scoop
Scoop/shims/scoop: line 8: syntax error: unexpected end of file

Expected Behavior

After scoop update "*"
Expected output running scoop

$ scoop
Usage: scoop <command> [<args>]

Some useful commands are:

alias       Manage scoop aliases
bucket      Manage Scoop buckets
cache       Show or clear the download cache
...

Additional context/output

Possible Solution

Editing the script by switching EOL from CRLF to LF fix the issue.

At the moment, "each" time scoop repo is updated this manual fix is overrided.

System details

Windows version: 10

OS architecture: 64bit

Additional software:
Current Scoop version:
5602083 (HEAD -> master, tag: 2021-12-26, origin/master, origin/HEAD) fix(schema): Add 'license' definition (#4596)

Runinng from cygwin (3.3.3(0.341/5/3)) and GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)

Scoop Configuration

@Sebourg Sebourg added the bug label Dec 31, 2021
@rashil2000
Copy link
Member

Hi, thanks for the report.

This is being handled in #4614 (review)

niheaven added a commit that referenced this issue Jan 1, 2022
Close #4616

Co-authored-by: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com>
@gavenkoa
Copy link

I've got the same issue:

...
Persisting lib
'jmeter' (5.4.3) was installed successfully!
/opt/scoop/shims/scoop: line 3: wsh.exe: command not found
/opt/scoop/shims/scoop: line 4: $'else\r': command not found
WARN  'jmeter' (5.4.3) is already installed.
Use 'scoop update jmeter' to install a new version.
/opt/scoop/shims/scoop: line 6: $'fi\r': command not found

bash# scoop install wsh
/opt/scoop/shims/scoop: line 8: syntax error: unexpected end of file

bash# scoop search
/opt/scoop/shims/scoop: line 8: syntax error: unexpected end of file

Now that I have broken scoop installation due to this error: how can I recover my installation?

I did it with Cygwin:

apt-cyg install dos2unix
dos2unix /opt/scoop/shims/scoop

but I'm not sure it fixes all places.

@rashil2000
Copy link
Member

rashil2000 commented Jan 20, 2022

Use globbing in bash to find all sh scripts (i.e. files without extensions) in the shims folder, and run dos2unix on them

@gavenkoa
Copy link

gavenkoa commented Feb 2, 2022

Any progress on this? After scoop update it is unusable from Cygwin's mintty...

Now I start using scoop from cmd ((

@rashil2000
Copy link
Member

It has been fixed, but not released. We should do a release soon. /cc @niheaven

@Sebourg
Copy link
Author

Sebourg commented Feb 12, 2022

Hi, @rashil2000, I checked out the fix #359cd81

When running scoop.sh after an update it still had an error. It's due to a residual ␍on the last line.

This is how the scoop.sh file looked when I used the patched core.ps1 file.

#!/bin/sh␊
# C:\Apps\Scoop\apps\scoop\current\bin\scoop.ps1␊
if command -v pwsh.exe &> /dev/null; then␊
    pwsh -noprofile -ex unrestricted -command "& 'C:\Apps\Scoop\apps\scoop\current\bin\scoop.ps1'  $@;exit \$lastexitcode"␊
else␊
    powershell -noprofile -ex unrestricted -command "& 'C:\Apps\Scoop\apps\scoop\current\bin\scoop.ps1'  $@;exit \$lastexitcode"␊
fi␍␊

Adding the parameter "-NoNewline" to the cmdlet Out-File should do the trick thus complete the fix by removing the last line.
It did work on my setup at least.

Cheers

@rashil2000
Copy link
Member

The newline part was fixed in a subsequent PR - https://github.com/ScoopInstaller/Scoop/pull/4637/files

@Sebourg
Copy link
Author

Sebourg commented Feb 12, 2022

Sweet 👍

@rashil2000
Copy link
Member

Closed in #4614

@Sebourg
Copy link
Author

Sebourg commented Mar 8, 2022

This issue persists

dummy@Winstation ~
$ scoop update "*"
Updating Scoop...
 * 04b30de9 chore(release): Bump to version 0.1.0                        7 hours ago
 * 750ea54d fix(shim): Fix `scoop which` error (#4780)                   21 hours ago
....
....
 * 7428fdece goreleaser: Update to version 1.6.1                         35 hours ago
Scoop was updated successfully!
Latest versions for all apps are installed! For more information try 'scoop status'

dummy@Winstation ~
$ scoop status
/cygdrive/c/Apps/Scoop/shims/scoop: line 8: syntax error: unexpected end of file

After update the sh file scoop still has CRLF endings

@rashil2000
Copy link
Member

Can you run scoop reset scoop and see?

@Sebourg
Copy link
Author

Sebourg commented Mar 8, 2022

I just run scoop reset scoop from the Windows Shell, as the sh scoop file is not runnable.
Then relauch a bash shell, try scoop status command, the issue still here.

scoop reset scoop doesn't appear to affect the sh scoop file as the last modified date of the sh scoop file has not changed after runinng this command.

On the other end, I just tried scoop update instead of scoop update "*", this seems to generate a proper sh scoop file. 👍

Looks like scoop update "*" updates every apps but scoop

@rashil2000
Copy link
Member

Looks like scoop update "*" updates every apps but scoop

Yes, you're right. I forgot about that :)

@gavenkoa
Copy link

gavenkoa commented Mar 9, 2022

I ran scoop update and problem persisted but after the next scoop reset scoop it disappeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants