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

REPL formatting messed up after LocalRegistry calls #76

Closed
KeithWM opened this issue Nov 12, 2023 · 15 comments · Fixed by #77
Closed

REPL formatting messed up after LocalRegistry calls #76

KeithWM opened this issue Nov 12, 2023 · 15 comments · Fixed by #77

Comments

@KeithWM
Copy link

KeithWM commented Nov 12, 2023

Hi,

First of all thanks for the great package, one of unsung heroes of the Julia community. Kudos!

I have a niggling little issue, but that still would be nice if it could be fixed. Unfortunately, I have to be a bit secretive about the content, but the crucial part of the output when using LocalRegistry within a package looks something like this.

[ Info: Project file successfully updated at C:\Users\k4-4549-9810-10178c73fb7b\***_local\***\
[ Info: Updated package C:\Users\***\.julia\scratcb7b\***_local\***\***
[ Info: Pushed *** to ***
┌ Info: Registering package
│   package_path = "C:\\Users\\***\\.julia\\scratcfb7b\\***_local\\***\\***
│   registry_path = "C:\\Users\\***\\.julia\\regis
│   package_repo = "C:\\Users\\***\\.julia\\scratcfb7b\\***_remote"
│   uuid = UUID("ba8d0a40-a93a-480c-b4e6-3037af7f5358")
│   version = v"0.6.7"
│   tree_hash = "cdcbfde76a4b675a4d70c70b02c6b2e054a838
└   subdir = "***/***
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your wo
warning: LF will be replaced by CRLF in A/***
The file will have its original line endings in your wo
warning: LF will be replaced by CRLF in A/***
The file will have its original line endings in your wo
warning: LF will be replaced by CRLF in A/***
The file will have its original line endings in your wo
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 1.14 KiB | 232.00 KiB/s, d
Total 9 (delta 2), reused 0 (delta 0), pack-reused 0
To C:\Users\***\.julia\scratchspaces\d7677818-5ae4
   d5bce7e..8e07e01  master -> master
Already on 'master'
Your branch is up to date with 'origin/master'.
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39m

Note how the last line "literally" prints whatever the magic is that usually give a neat bold and light blue [Info]. I suspect this has something to do with the call to git, but it would be much appreciated if this could be solved.

@GunnarFarneback
Copy link
Owner

GunnarFarneback commented Nov 13, 2023

This is nothing I can reproduce, so it would be helpful with more information. You're obviously running this on windows but what terminal are you running and does it make a difference if you switch to another one?

It would also help a lot with a complete example reproducing the problem. Can you get this to happen if you create a new registry and register, say, the Example package? Tips:

  • You can use a file:// URL to avoid involving any server, c.f.
    create_registry(registry_push_dir, "file://$(upstream_dir)", push = true,
    Alternatively enter a fake URL and use all commands with push = false, assuming it's not specifically the git push that's problematic.
  • You can register a package from General in your own registry simply by doing
pkg> dev Example
julia> using Example
julia> register(Example, registry = "YourTestRegistry")

Even better would be an example which only involves calling out to git and doing @info.

@KeithWM
Copy link
Author

KeithWM commented Nov 13, 2023

Thanks for the response, I will try to create some M(N)WE with the info you provided, I will get back to you later.

@KeithWM
Copy link
Author

KeithWM commented Nov 13, 2023

Actually just running ]test is sufficient to reproduce the issue.

vers = "Version 0.20.0"
[ Info: nothing to commit
┌ Info: Registering package
│   package_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTestsil6Kz9\\packages\\Images"
│   registry_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTestsil6Kz9\\test2\\TestRegistry"
│   package_repo = ""
│   uuid = UUID("916415d5-f1e6-5110-898d-aaa5f9f070e0")
│   version = v"0.20.0"
│   tree_hash = "f5255a0dcd15f44c762f60da696d06de439859dc"
└   subdir = ""
warning: LF will be replaced by CRLF in I/Images/Compat.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in I/Images/Deps.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in I/Images/Package.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in I/Images/Versions.toml.
The file will have its original line endings in your working directory
Already on 'master'
warning: LF will be replaced by CRLF in LICENSE.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/Flux.jl.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in test/runtests.jl.
The file will have its original line endings in your working directory
vers = "Version 0.9.9"
[ Info: nothing to commit
┌ Info: Registering package
│   package_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTestsil6Kz9\\packages\\Flux"
│   registry_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTestsil6Kz9\\test2\\TestRegistry"
│   package_repo = ""
│   uuid = UUID("587475ba-b771-5e3f-ad9e-33799f191a9c")
│   version = v"0.9.9"
│   tree_hash = "6be0b04bdfbc1869ea941053b4dc01f240909b1b"
└   subdir = ""
warning: LF will be replaced by CRLF in F/Flux/Compat.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in F/Flux/Deps.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in F/Flux/Package.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in F/Flux/Versions.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in I/Images/Compat.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in I/Images/Deps.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in I/Images/Package.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in I/Images/Versions.toml.
The file will have its original line endings in your working directory
Already on 'master'
Test Summary:    | Pass  Total     Time
Regression tests |    6      6  1m51.6s
Cloning into '.'...
warning: You appear to have cloned an empty repository.
Switched to a new branch 'some_unusual_branch_name'
[some_unusual_branch_name (root-commit) 08889c5] Initial version
 1 file changed, 1 insertion(+)
 create mode 100644 .gitignore
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 242 bytes | 242.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To file://C:\Users\***\AppData\Local\Temp\LocalRegistryTestsrqachM\upstream_registry
 * [new branch]      some_unusual_branch_name -> some_unusual_branch_name
Branch 'some_unusual_branch_name' set up to track remote branch 'some_unusual_branch_name' from 'origin'.
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your working directory
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 446 bytes | 446.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To file://C:\Users\***\AppData\Local\Temp\LocalRegistryTestsrqachM\upstream_registry
   08889c5..92cc4c1  HEAD -> some_unusual_branch_name
Branch 'some_unusual_branch_name' set up to track remote branch 'some_unusual_branch_name' from 'origin'.
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mCreated registry in directory C:\Users\***\AppData\Local\Temp\LocalRegistryTestsrqachM\downstream_registry
warning: You appear to have cloned an empty repository.
Switched to a new branch 'my_favorite_branch_name'
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your working directory
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 380 bytes | 380.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To file://C:\Users\***\AppData\Local\Temp\LocalRegistryTestsfw9Z2b\upstream_registry
 * [new branch]      HEAD -> my_favorite_branch_name
Branch 'my_favorite_branch_name' set up to track remote branch 'my_favorite_branch_name' from 'origin'.
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mCreated registry in directory C:\Users\***\AppData\Local\Temp\LocalRegistryTestsfw9Z2b\downstream_registry
[0m[1mTest Summary:   | [22m[32m[1mPass  [22m[39m[36m[1mTotal  [22m[39m[0m[1mTime[22m
Create registry | [32m   2  [39m[36m    2  [39m[0m3.9s
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your working directory
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mCreated registry in directory C:\Users\***\AppData\Local\Temp\LocalRegistryTests26CSaQ\TestRegistry
warning: LF will be replaced by CRLF in LICENSE.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/Flux.jl.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in test/runtests.jl.
The file will have its original line endings in your working directory
vers = "Version 0.10.1"
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mnothing to commit
[36m[1m┌ [22m[39m[36m[1mInfo: [22m[39mRegistering package
[36m[1m│ [22m[39m  package_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTests26CSaQ\\packages\\Flux"
[36m[1m│ [22m[39m  registry_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTests26CSaQ\\TestRegistry"
[36m[1m│ [22m[39m  package_repo = "[email protected]:Julia/Flux.jl.git"
[36m[1m│ [22m[39m  uuid = UUID("587475ba-b771-5e3f-ad9e-33799f191a9c")
[36m[1m│ [22m[39m  version = v"0.10.1"
[36m[1m│ [22m[39m  tree_hash = "72f64dfebeb8e82525f918b7b4fcc38c0cae97c9"
[36m[1m└ [22m[39m  subdir = ""
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in F/Flux/Compat.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in F/Flux/Deps.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in F/Flux/Package.toml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in F/Flux/Versions.toml.
The file will have its original line endings in your working directory
Already on 'master'
warning: LF will be replaced by CRLF in LICENSE.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/Flux.jl.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in test/runtests.jl.
The file will have its original line endings in your working directory
vers = "Version 0.10.1"
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mnothing to commit
[36m[1m┌ [22m[39m[36m[1mInfo: [22m[39mRegistering package
[36m[1m│ [22m[39m  package_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTests26CSaQ\\packages\\Flux"
[36m[1m│ [22m[39m  registry_path = "C:\\Users\\***\\AppData\\Local\\Temp\\LocalRegistryTests26CSaQ\\TestRegistry"
[36m[1m│ [22m[39m  package_repo = ""
[36m[1m│ [22m[39m  uuid = UUID("587475ba-b771-5e3f-ad9e-33799f191a9c")
[36m[1m│ [22m[39m  version = v"0.10.1"
[36m[1m│ [22m[39m  tree_hash = "c2368de6ad5d929913f86091b00cfeecb52dec63"
[36m[1m└ [22m[39m  subdir = ""
HEAD is now at b77f702 New package: Flux v0.10.1
Already on 'master'
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mThis version has already been registered. Registration request is ignored. Update the version number to register a new version.
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your working directory
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mCreated registry in directory C:\Users\***\AppData\Local\Temp\LocalRegistryTestszggfcD\TestRegistry
warning: LF will be replaced by CRLF in LICENSE.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in sr

To narrow it down further, I commented out all tests except create_registry.jl and already see the issue right away.

(LocalRegistry) pkg> test
     Testing LocalRegistry
      Status `C:\Users\***\AppData\Local\Temp\jl_AG6gXz\Project.toml`
  [944b1d66] CodecZlib v0.7.3
  [89398ba2] LocalRegistry v0.5.5 `C:\Users\***\.julia\dev\LocalRegistry`
  [2792f1a3] RegistryInstances v0.1.0
  [d1eb7eb1] RegistryTools v2.2.3
  [44cfe95a] Pkg v1.9.0 `@stdlib/Pkg`
  [9a3f8284] Random `@stdlib/Random`
  [fa267f1f] TOML v1.0.3 `@stdlib/TOML`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
      Status `C:\Users\***\AppData\Local\Temp\jl_AG6gXz\Manifest.toml`
⌅ [15f4f7f2] AutoHashEquals v0.2.0
  [944b1d66] CodecZlib v0.7.3
  [0e77f7df] LazilyInitializedFields v1.2.1
  [89398ba2] LocalRegistry v0.5.5 `C:\Users\***\.julia\dev\LocalRegistry`
  [2792f1a3] RegistryInstances v0.1.0
  [d1eb7eb1] RegistryTools v2.2.3
  [3bb67fe8] TranscodingStreams v0.10.2
  [0dad84c5] ArgTools v1.1.1 `@stdlib/ArgTools`
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [f43a241f] Downloads v1.6.0 `@stdlib/Downloads`
  [7b1f6079] FileWatching `@stdlib/FileWatching`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [b27032c2] LibCURL v0.6.3 `@stdlib/LibCURL`
  [76f85450] LibGit2 `@stdlib/LibGit2`
  [8f399da3] Libdl `@stdlib/Libdl`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [ca575930] NetworkOptions v1.2.0 `@stdlib/NetworkOptions`
  [44cfe95a] Pkg v1.9.0 `@stdlib/Pkg`
  [de0858da] Printf `@stdlib/Printf`
  [3fa0cd96] REPL `@stdlib/REPL`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA v0.7.0 `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [fa267f1f] TOML v1.0.3 `@stdlib/TOML`
  [a4e569a6] Tar v1.10.0 `@stdlib/Tar`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [deac9b47] LibCURL_jll v7.84.0+0 `@stdlib/LibCURL_jll`
  [29816b5a] LibSSH2_jll v1.10.2+0 `@stdlib/LibSSH2_jll`
  [c8ffd9c3] MbedTLS_jll v2.28.2+0 `@stdlib/MbedTLS_jll`
  [14a3606d] MozillaCACerts_jll v2022.10.11 `@stdlib/MozillaCACerts_jll`
  [83775a58] Zlib_jll v1.2.13+0 `@stdlib/Zlib_jll`
  [8e850ede] nghttp2_jll v1.48.0+0 `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll v17.4.0+0 `@stdlib/p7zip_jll`
        Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading.
     Testing Running tests...
    Updating registry at `C:\Users\***\.julia\registries\JuliaComputingRegistry.toml`
   Resolving package versions...
    Updating `C:\Users\***\AppData\Local\Temp\jl_AG6gXz\Project.toml`
⌅ [15f4f7f2] + AutoHashEquals v0.2.0
    Updating `C:\Users\***\AppData\Local\Temp\jl_AG6gXz\Manifest.toml`
⌃ [3bb67fe8]  TranscodingStreams v0.10.2  v0.10.1
  [0dad84c5] ~ ArgTools v1.1.1 `@stdlib/ArgTools`  v1.1.1
  [56f22d72] ~ Artifacts `@stdlib/Artifacts`  
  [2a0f44e3] ~ Base64 `@stdlib/Base64`  
  [ade2ca70] ~ Dates `@stdlib/Dates`  
  [f43a241f] ~ Downloads v1.6.0 `@stdlib/Downloads`  v1.6.0
  [7b1f6079] ~ FileWatching `@stdlib/FileWatching`  
  [b77e0a4c] ~ InteractiveUtils `@stdlib/InteractiveUtils`  
  [b27032c2] ~ LibCURL v0.6.3 `@stdlib/LibCURL`  v0.6.3
  [76f85450] ~ LibGit2 `@stdlib/LibGit2`  
  [8f399da3] ~ Libdl `@stdlib/Libdl`  
  [56ddb016] ~ Logging `@stdlib/Logging`  
  [d6f4376e] ~ Markdown `@stdlib/Markdown`  
  [ca575930] ~ NetworkOptions v1.2.0 `@stdlib/NetworkOptions`  v1.2.0
  [de0858da] ~ Printf `@stdlib/Printf`  
  [3fa0cd96] ~ REPL `@stdlib/REPL`  
  [ea8e919c] ~ SHA v0.7.0 `@stdlib/SHA`  v0.7.0
  [9e88b42a] ~ Serialization `@stdlib/Serialization`  
  [6462fe0b] ~ Sockets `@stdlib/Sockets`  
  [a4e569a6] ~ Tar v1.10.0 `@stdlib/Tar`  v1.10.0
  [4ec0a83e] ~ Unicode `@stdlib/Unicode`  
  [deac9b47] ~ LibCURL_jll v7.84.0+0 `@stdlib/LibCURL_jll`  v7.84.0+0
  [29816b5a] ~ LibSSH2_jll v1.10.2+0 `@stdlib/LibSSH2_jll`  v1.10.2+0
  [c8ffd9c3] ~ MbedTLS_jll v2.28.2+0 `@stdlib/MbedTLS_jll`  v2.28.2+0
  [14a3606d] ~ MozillaCACerts_jll v2022.10.11 `@stdlib/MozillaCACerts_jll`  v2022.10.11
  [83775a58] ~ Zlib_jll v1.2.13+0 `@stdlib/Zlib_jll`  v1.2.13+0
  [8e850ede] ~ nghttp2_jll v1.48.0+0 `@stdlib/nghttp2_jll`  v1.48.0+0
  [3f19e933] ~ p7zip_jll v17.4.0+0 `@stdlib/p7zip_jll`  v17.4.0+0
        Info Packages marked with ⌃ have new versions available and may be upgradable.
     Cloning git-repo `https://github.com/GunnarFarneback/Multibreak.jl.git`
   Resolving package versions...
    Updating `C:\Users\***\AppData\Local\Temp\jl_AG6gXz\Project.toml`
  [2db7fbaf] + Multibreak v0.2.0 `dev\Multibreak`
    Updating `C:\Users\***\AppData\Local\Temp\jl_AG6gXz\Manifest.toml`
  [2db7fbaf] + Multibreak v0.2.0 `dev\Multibreak`
Cloning into '.'...
warning: You appear to have cloned an empty repository.
Switched to a new branch 'some_unusual_branch_name'
[some_unusual_branch_name (root-commit) d5d73e9] Initial version
 1 file changed, 1 insertion(+)
 create mode 100644 .gitignore
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 242 bytes | 242.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To file://C:\Users\***\AppData\Local\Temp\LocalRegistryTestsriX3lP\upstream_registry
 * [new branch]      some_unusual_branch_name -> some_unusual_branch_name
Branch 'some_unusual_branch_name' set up to track remote branch 'some_unusual_branch_name' from 'origin'.
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your working directory
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 451 bytes | 451.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To file://C:\Users\***\AppData\Local\Temp\LocalRegistryTestsriX3lP\upstream_registry
   d5d73e9..88d8b46  HEAD -> some_unusual_branch_name
Branch 'some_unusual_branch_name' set up to track remote branch 'some_unusual_branch_name' from 'origin'.
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mCreated registry in directory C:\Users\***\AppData\Local\Temp\LocalRegistryTestsriX3lP\downstream_registry
warning: You appear to have cloned an empty repository.
Switched to a new branch 'my_favorite_branch_name'
warning: LF will be replaced by CRLF in Registry.toml.
The file will have its original line endings in your working directory
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 379 bytes | 379.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To file://C:\Users\***\AppData\Local\Temp\LocalRegistryTestsihTc1D\upstream_registry
 * [new branch]      HEAD -> my_favorite_branch_name
Branch 'my_favorite_branch_name' set up to track remote branch 'my_favorite_branch_name' from 'origin'.
[36m[1m[ [22m[39m[36m[1mInfo: [22m[39mCreated registry in directory C:\Users\***\AppData\Local\Temp\LocalRegistryTestsihTc1D\downstream_registry
[0m[1mTest Summary:   | [22m[32m[1mPass  [22m[39m[36m[1mTotal  [22m[39m[0m[1mTime[22m
Create registry | [32m   2  [39m[36m    2  [39m[0m5.4s
[32m[1m     Testing[22m[39m LocalRegistry tests passed

I have OhMyREPL in my startup, alongside ReVise and TestEnv, but I have also tested without (on (LocalRegistry) pkg> test) that the issue persists with all three disabled.

@KeithWM
Copy link
Author

KeithWM commented Nov 13, 2023

I can work around this with IOCapture.capture(). It does suggest the issue is actually not within LocalRegistry, but in run that fails to keep a nice REPL if the command in question causes a warning (at least, I think it's only when there's a warning).

@GunnarFarneback
Copy link
Owner

I can reproduce this behavior in a Windows CMD by only doing

julia> run(`git clone file:///foo`)
Cloning into 'foo'...
fatal: 'C:/Program Files/Git/foo' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
←[91m←[1mERROR: ←[22m←[39mfailed process: Process(`←[4mgit←[24m ←[4mclone←[24m ←[4mfile:///foo←[24m`, ProcessExited(128)) [128]

Stacktrace:
 [1] ←[0m←[1mpipeline_error←[22m
←[90m   @←[39m ←[90m.\←[39m←[90m←[4mprocess.jl:565←[24m←[39m←[90m [inlined]←[39m
 [2] ←[0m←[1mrun←[22m←[0m←[1m(←[22m::←[0mCmd; ←[90mwait←[39m::←[0mBool←[0m←[1m)←[22m
←[90m   @←[39m ←[90mBase←[39m ←[90m.\←[39m←[90m←[4mprocess.jl:480←[24m←[39m
 [3] ←[0m←[1mrun←[22m←[0m←[1m(←[22m::←[0mCmd←[0m←[1m)←[22m
←[90m   @←[39m ←[90mBase←[39m ←[90m.\←[39m←[90m←[4mprocess.jl:477←[24m←[39m
 [4] top-level scope
←[90m   @←[39m ←[90m←[4mREPL[4]:1←[24m←[39m

This seems to happen only for some git commands. I see nothing strange if I capture the stderr output and nothing odd happens when I run the git clone directly in CMD.

Possibly something is going on with SetConsoleMode, cf. https://discourse.julialang.org/t/strange-characters-in-windows-terminal/89355.

@GunnarFarneback
Copy link
Owner

I found some useful information in ziglang/zig#16526. Essentially this is most likely a bug in git on Windows but there may be ways to work around it.

@GunnarFarneback
Copy link
Owner

Please check whether #77 solves your problem.

@KeithWM
Copy link
Author

KeithWM commented Nov 13, 2023

Yes it does. Thank you!

@GunnarFarneback
Copy link
Owner

If you feel like it, it would be interesting to know how the updated #38 fares in this respect, without or with

external_git = `cmd /c git`

@KeithWM
Copy link
Author

KeithWM commented Nov 16, 2023

I can give this a go tomorrow when I'm back on my Windows machine.

Is there a clear consensus on what is the best way to use git from within Julia? I recently implemented something using LibGit2 (in the same project that brought me here), but I wasn't too enamoured with it.

@KeithWM
Copy link
Author

KeithWM commented Nov 16, 2023

Silly me opened my work laptop this evening and already gave it a go. I get a failure on the first test I try (create registry).

Cloning into '.'...
error: cannot spawn sh: No such file or directory
fatal: unable to fork
Create registry: Error During Test at C:\Users\****\.julia\dev\LocalRegistry\test\runtests.jl:36
  Got exception outside of a @test
  LoadError: failed process: Process(setenv(`'C:\Users\****\.julia\artifacts\1369cfb65487d87433be1bf212676aaef5bfd579\bin\git.exe' -C 'C:\Users\****\AppData\Local\Temp\LocalRegistryTestsF5t692\tmp_downstream' -c user.name=LocalRegistryTests -c core.autocrlf=input -c [email protected] clone 'file://C:\Users\****\AppData\Local\Temp\LocalRegistryTestsF5t692\upstream_registry' .`,["WINDIR=C:\\WINDOWS", "PATH=C:\\Users\\****\\AppData\\Local\\Programs\\Julia-1.9.0\\bin;C:\\Users\\****\\.julia\\artifacts\\dafc9a0c7041340143802ddda690559e5e012daa\\bin;C:\\Users\\****\\.julia\\artifacts\\44674b9d75b9ab80ffb7f6782a04dbd0f09b8bbb\\bin;C:\\Users\\****\\.julia\\artifacts\\81aa39275e8fd66d1457857d24fccb2023955b87\\bin;C:\\Users\\****\\AppData\\Local\\Programs\\Julia-1.9.0\\bin\\..\\lib\\julia;C:\\Users\\****\\AppData\\Local\\Programs\\Julia-1.9.0\\bin\\..\\lib;C:\\Users\\****\\AppData\\Local\\Programs\\Julia-1.9.0\\bin;C:\\Program Files (x86)\\Python37-32\\Scripts\\;C:\\Program Files (x86)... # redacted #

  Stacktrace:
    [1] pipeline_error
      @ .\process.jl:565 [inlined]
    [2] run(::Cmd; wait::Bool)
      @ Base .\process.jl:480
    [3] run
      @ .\process.jl:477 [inlined]
    [4] (::var"#6#7")(testdir::String)
      @ Main C:\Users\****\.julia\dev\LocalRegistry\test\create_registry.jl:20
    [5] with_testdir(f::var"#6#7")
      @ Main C:\Users\****\.julia\dev\LocalRegistry\test\utils.jl:164
    [6] top-level scope
      @ C:\Users\****\.julia\dev\LocalRegistry\test\create_registry.jl:4
    [7] include(fname::String)
      @ Base.MainInclude .\client.jl:478
    [8] macro expansion
      @ C:\Users\****\.julia\dev\LocalRegistry\test\runtests.jl:37 [inlined]
    [9] macro expansion
      @ C:\Users\****\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\Test\src\Test.jl:1498 
[inlined]
   [10] top-level scope
      @ C:\Users\****\.julia\dev\LocalRegistry\test\runtests.jl:37
   [11] include(fname::String)
      @ Base.MainInclude .\client.jl:478
   [12] top-level scope
      @ none:6
   [13] eval
      @ .\boot.jl:370 [inlined]
   [14] exec_options(opts::Base.JLOptions)
      @ Base .\client.jl:280
   [15] _start()
      @ Base .\client.jl:522
  in expression starting at C:\Users\****\.julia\dev\LocalRegistry\test\create_registry.jl:4
Test Summary:   | Error  Total  Time
Create registry |     1      1  5.2s
ERROR: LoadError: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.
in expression starting at C:\Users\****\.julia\dev\LocalRegistry\test\runtests.jl:36
ERROR: Package LocalRegistry errored during testing

@GunnarFarneback
Copy link
Owner

Generally speaking it's usually nicer to ccall into a library rather than calling out to a binary but git is a bit special in this respect. To begin with Julia was using command line git for its package manager but due to the design at that time, lots of calls were needed and took a long time, see JuliaLang/julia#4158. Libgit2 solved that problem and is nice for some operations but on the whole less complete than command line git. The real headache with Libgit2 has been when used with ssh keys, since Libssh2 is considerably less capable than command line ssh. In Julia 1.7 the option to again use command line git was added and the general plan is to eventually migrate away from Libgit2/Libssh2.

@GunnarFarneback
Copy link
Owner

That's considerably worse than Windows CI is doing and it seems strange that it would try to run sh on Windows. Does the Git package pass its tests on your computer?

Does create_registry(...; external_git = "git") work better?

@KeithWM
Copy link
Author

KeithWM commented Nov 18, 2023

Git's tests also fail.

Setting the kwarg does not remove the sh error.

(Sorry for the short message, bit busy, but did want to at least report back my immediate findings.)

@GunnarFarneback
Copy link
Owner

I think I know what is the problem. Most git commands are included in the git executable, but a few are (still) implemented as shell scripts. Thus it's git itself that tries to spawn sh, which works if and only if you have an external git installation which has been configured to make git bash available from PATH. (The external git makes this work anyway but presumably Git_jll and/or the Git package is not sufficiently complete.)

So #38 will have to wait a while longer until this gets ironed out in the Git package.

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