Skip to content

Conversation

@yhkee0404
Copy link
Contributor

@yhkee0404 yhkee0404 commented Mar 8, 2025

Note

I found that my Windows 11's built-in Windows PowerShell has the following issue while the one I downloaded from Microsoft Store does not. The version of the former is 5.1 and that of the latter is 7.5.0. Still, I suggest a fix that works in both versions.

Description

On Linux, I verified that test environment configuration of Julia works with the following lines of code:

echo "Setting up Julia environment"
if [ -z $uv_exist ]
then
uv run --frozen julia --color=yes --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.build("IJulia"); Pkg.precompile()'
else
julia --color=yes --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.build("IJulia"); Pkg.precompile()'
fi

What if the double quotes in "IJulia" were omitted? Then it would not work as the following log shows:

root@8aadfbdbf62f:~# julia -e 'println("IJulia")'
IJulia
root@8aadfbdbf62f:~# julia -e 'println(IJulia)'
ERROR: UndefVarError: `Hello` not defined in `Main`
Stacktrace:
 [1] top-level scope
   @ none:1

In fact, the very same error happens on Windows unlike on Linux with the following lines of code because of incomplete escape of double quotes with backticks(`):

If ($julia) {
# TODO: Check to do equivalent of virtualenv
Write-Host "Setting up Julia environment"
uv run --frozen julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.build(`"IJulia`"); Pkg.precompile()"
}

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      26100  2161
PS C:\> julia -e "println(`"Hello`")"
ERROR: UndefVarError: `Hello` not defined in `Main`
Stacktrace:
 [1] top-level scope
   @ none:1
PS C:\> julia -e "println(Hello)"
ERROR: UndefVarError: `Hello` not defined in `Main`
Stacktrace:
 [1] top-level scope
   @ none:1

I selected the second option from the following four approaches because it works both on Windows 11's built-in Windows PowerShell (version 5.1) and Microsoft Store's PowerShell (version 7.5.0), and the single quotes are also used in the corresponding Linux command:

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      26100  2161
PS C:\> julia -e 'println(\"Hello\")'
Hello
PS C:\> julia -e 'println("""Hello""")'
Hello
PS C:\> julia -e "println(\`"Hello\`")"
Hello
PS C:\> julia -e "println(""""""Hello"""""")"
Hello
PS C:\> $PSVersionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      5      0

PS C:\> julia -e 'println(\"Hello\")'
ERROR: ParseError:
# Error @ none:1:9
println(\"Hello\")
#       ╙ ── not a unary operator
Stacktrace:
 [1] top-level scope
   @ none:1
PS C:\> julia -e 'println("""Hello""")'
Hello
PS C:\> julia -e "println(\`"Hello\`")"
ERROR: ParseError:
# Error @ none:1:9
println(\"Hello\")
#       ╙ ── not a unary operator
Stacktrace:
 [1] top-level scope
   @ none:1
PS C:\> julia -e "println(""""""Hello"""""")"
Hello

Checklist

I have (if applicable):

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you !

I am the only developer using Windows in the Team, and I use Powershell 7. We didn't really expect anyone to use Powershell 5 to run the tests.

This fix is easy enough with low impact so I'll merge it, but I don't warranty that there won't be anymore problem.

To me, using Powershell 7 is recommended use develop with Quarto.

Thanks again for the PR !

@cderv cderv merged commit 1831dfd into quarto-dev:main Mar 10, 2025
47 checks passed
@yhkee0404 yhkee0404 deleted the test-env-julia-windows branch March 10, 2025 11:47
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 this pull request may close these issues.

2 participants