Closed Bamii closed 11 months ago
Hello! I'm having trouble reproducing this. Could you share more information please?
What operating system are you using?
How did you install Gleam and Elixir?
Could you share everything Gleam prints to the console after you run gleam run
đ
Thank you
@lpil
OS: Windows 11
Installed Gleam & Elixir using scoop
so, its even crazier because if i create a new project and just do these steps... it works fine. but on this one project i'm working on, it breaks. (and i just found out i don't need to import the library, mere installing it breaks the program)
gleam.toml
version = "0.1.0"
gleam = ">= 0.32.0"
[dependencies]
gleam_stdlib = "~> 0.31"
gleam_http = "~> 3.5"
gleam_json = "~> 0.6"
gleam_erlang = "~> 0.22"
gleam_hackney = "~> 1.1"
finch_gleam = "~> 4.0"
[dev-dependencies]
gleeunit = "~> 0.10"
sequence of events i took to reproduce:
PS C:\Users\ACER-PC\Documents\work\openai> gleam remove finch_gleam // to make sure its uninstalled.
Removed finch_gleam
PS C:\Users\ACER-PC\Documents\work\openai> gleam run
Compiling openai
Compiled in 0.44s
Running openai.main
body!!
"{\"model\":\"gpt-3.5-turbo\",\"messages\":[{\"role\":\"user\",\"content\":\"conjugate these words === avoir, etre, defiler, entrer ===\"}],\"mod
el\":\"gpt-3.5-turbo\"}"
PS C:\Users\ACER-PC\Documents\work\openai> gleam add finch_gleam
Resolving versions
Downloading packages
Downloaded 9 packages in 0.13s
Added finch_gleam v4.0.0
PS C:\Users\ACER-PC\Documents\work\openai> gleam run
Resolving versions
Compiling hpax
Compiling castore
Compiling mint
Compiling mime
Compiling telemetry
===> Analyzing applications...
===> Compiling telemetry
Compiling nimble_options
Compiling nimble_pool
Compiling finch
warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
lib/finch/http2/pool.ex:362: Finch.HTTP2.Pool.connected/3
warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
lib/finch/http2/pool.ex:460: Finch.HTTP2.Pool.connected_read_only/3
Compiling finch_gleam
warning: Deprecated BitString name used
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch\stream.gleam:7:14
â
7 â Data(data: BitString)
â ^^^^^^^^^
The type BitString has been renamed to BitArray.
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch\stream.gleam:1:23
â
1 â import finch/headers.{Headers as ReqHeaders}
â ^^^^^^^
The syntax for importing a type has changed. The new syntax is:
import module.{type Headers}
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch\otp.gleam:6:27
â
6 â import gleam/erlang/atom.{Atom}
â ^^^^
The syntax for importing a type has changed. The new syntax is:
import module.{type Atom}
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch\otp.gleam:5:19
â
5 â import gleam/map.{Map}
â ^^^
The syntax for importing a type has changed. The new syntax is:
import module.{type Map}
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch\otp.gleam:4:23
â
4 â import gleam/dynamic.{Dynamic}
â ^^^^^^^
The syntax for importing a type has changed. The new syntax is:
import module.{type Dynamic}
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch\otp.gleam:7:30
â
7 â import gleam/erlang/process.{Pid}
â ^^^
The syntax for importing a type has changed. The new syntax is:
import module.{type Pid}
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch\otp.gleam:8:23
â
8 â import finch/timeout.{Timeout}
â ^^^^^^^
The syntax for importing a type has changed. The new syntax is:
import module.{type Timeout}
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch.gleam:14:22
â
14 â import finch/stream.{StreamFun}
â ^^^^^^^^^
The syntax for importing a type has changed. The new syntax is:
The syntax for importing a type has changed. The new syntax is:
import module.{type InstanceOptions}
Hint: Run `gleam fix` to auto-fix your code.
warning: Deprecated type import
ââ C:\Users\ACER-PC\Documents\work\openai\build\packages\finch_gleam\src\finch.gleam:13:23
â
13 â import finch/headers.{Headers}
â ^^^^^^^
The syntax for importing a type has changed. The new syntax is:
import module.{type Headers}
Hint: Run `gleam fix` to auto-fix your code.
Compiled in 15.44s
Running openai.main
exception error: no match of right hand side value
{error,{elixir,{"no such file or directory","elixir.app"}}}
PS C:\Users\ACER-PC\Documents\work\openai> gleam fix
Your Gleam code has been fixed!
If you have any JavaScript code that used the BitString class
you will need to update it to use the BitArray class instead.
PS C:\Users\ACER-PC\Documents\work\openai> gleam run
Compiling openai
warning: Unused imported module
ââ C:\Users\ACER-PC\Documents\work\openai\src\api.gleam:4:1
â
4 â import chat/models as chat_models
â ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This imported module is never used.
Hint: You can safely remove it.
Compiled in 0.47s
Running openai.main
exception error: no match of right hand side value
{error,{elixir,{"no such file or directory","elixir.app"}}}
Very strange. Could you share what the openai
module looks like?
inside src/ all the files are empty... except
opeapi.gleam
which contains the main function. (i tried emptying this file too, so that theres just a main function that prints out something, same error occured.)api.gleam
which contains some gleam/http/request builders and chat.gleam
which contains some functions..I get the same issue when I run gleam run
without Administrator terminal at first.
gleam add floki
(adds an Elixir dependency)gleam run
. This will fail by creating symbol link build/dev/erlang/eex
without Administrator privilege. But build/dev/erlang/gleam_elixir_paths
still exists as if build/dev/erlang/{eex, elixir, logger, mix}
was successful created.gleam run
again. Symbol link build/dev/erlang/floki
is created. Starting OTP application floki
will fail because application elixir
does not exist at build/dev/erlang/elixir
.To fix it, remove build/dev/erlang/gleam_elixir_paths
, edit some source codes to force re-compiling.
Ah fantastic, that's really useful! Thank you so much!
Would you be able to test tomorrow with the nightly build please? đ
I don't know if @Bamii 's trouble was caused by the privilege issue, but the privilege issue isn't fix by 11146add8e63f51a9d82d463b91901528766b71f
The problem is, normal users cannot create symbol links on Windows. This limitation is introduced by system api CreateSymbolicLinkW.
Maybe we could remove build/{target}/erlang/gleam_elixir_paths
if failed creating symbol links at https://github.com/gleam-lang/gleam/blob/11146add8e63f51a9d82d463b91901528766b71f/compiler-core/src/build/package_compiler.rs#L530 and warn the lacking of privilege on windows
Or append Elixir's ebin paths with -pa <ebin path>
separately when gleam run
, instead of creating their symbol links together with dependencies?
Oh I see! Sorry, I have misunderstood the problem. I thought the symlink operation was silently failing, but instead it was that it fails but the build tool did not clean up the directories as required.
Would you be able to show me what the error looks like?
Adding the Elixir ebin paths is a great idea! It's not trivial to implement that so I'll make an issue for it.
Outputs of normal user:
~/projects $ gleam new hello
Your Gleam project hello has been successfully created.
The project can be compiled and tested by running these commands:
cd hello
gleam test
~/projects $ cd hello
~/projects/hello $ gleam add floki
Resolving versions
Downloading packages
Downloaded 3 packages in 0.08s
Added floki v0.35.2
~/projects/hello $ gleam run
Resolving versions
Compiling gleam_stdlib
Compiling gleeunit
Compiling floki
error: File IO failure
An error occurred while trying to link this file:
D:\home\fw\projects\hello\build\dev\erlang\eex
The error message from the file IO library was:
厢ćˇçŤŻć˛Ąććéççšćă (os error 1314)
~/projects/hello $
The chinese words means "A required privilege is not held by the client."
Outputs of Administrator terminal:
~/projects/hello # gleam run
Compiling floki
Compiling hello
Compiled in 3.62s
Running hello.main
exception error: no match of right hand side value
{error,{elixir,{"no such file or directory","elixir.app"}}}
~/projects/hello # gleam clean
~/projects/hello # gleam run
Downloading packages
Downloaded 3 packages in 0.06s
Compiling gleam_stdlib
Compiling floki
Compiling gleeunit
Compiling hello
Compiled in 5.52s
Running hello.main
Hello from hello!
~/projects/hello #
Thank you. Does using the nightly now result in the error happening every time gleam build
is run without the elevated permissions?
Every time.
~/projects/hello $ git -C ~\projects\gleam log --oneline -n 1
6ac9134 (HEAD -> main, origin/main, origin/HEAD) Prompt to create git tags
~/projects/hello $ ~\projects\gleam\target\release\gleam.exe run
Downloading packages
Downloaded 3 packages in 0.06s
Compiling gleam_stdlib
d:/home/fw/projects/hello/build/dev/erlang/gleam_stdlib/_gleam_artefacts/gleam@float.erl:166:21: Warning: this clause cannot match because a previous clause at line 165 always matches
% 166| -0.0 -> -0.0;
% | ^
Compiling gleeunit
Compiling floki
error: Fatal compiler bug!
This is a bug in the Gleam compiler, sorry!
Please report this crash to https://github.com/gleam-lang/gleam/issues/new
with this information and the code that produces the crash.
D:\home\fw\projects\gleam\compiler-core\src\build\elixir_libraries.rs:53
deleting paths cache in cleanup: FileIo { kind: Directory, action: Delete, path: "D:\\home\\fw\\projects\\hello\\build\\dev\\erlang\\gleam_elixir_paths", err: Some("çŽĺ˝ĺ称ć ćă (os error 267)") }
~/projects/hello $ ~\projects\gleam\target\release\gleam.exe run
Compiling floki
error: File IO failure
An error occurred while trying to link this file:
D:\home\fw\projects\hello\build\dev\erlang\floki
The error message from the file IO library was:
厢ćˇçŤŻć˛Ąććéççšćă (os error 1314)
~/projects/hello $ ~\projects\gleam\target\release\gleam.exe run
Compiling floki
error: File IO failure
An error occurred while trying to link this file:
D:\home\fw\projects\hello\build\dev\erlang\floki
The error message from the file IO library was:
厢ćˇçŤŻć˛Ąććéççšćă (os error 1314)
~/projects/hello $
Still the same, with https://github.com/gleam-lang/gleam/pull/2422
~/projects/hello $ rm -rf build\
~/projects/hello $ git -C ~\projects\gleam log --oneline -n 1
a5e0f52 (HEAD -> main, origin/main, origin/HEAD) Fix: `delete` should be `delete_file`
~/projects/hello $ ~\projects\gleam\target\release\gleam.exe run
Downloading packages
Downloaded 3 packages in 0.07s
Compiling floki
error: File IO failure
An error occurred while trying to link this file:
D:\home\fw\projects\hello\build\dev\erlang\eex
The error message from the file IO library was:
厢ćˇçŤŻć˛Ąććéççšćă (os error 1314)
~/projects/hello $ ~\projects\gleam\target\release\gleam.exe run
Compiling gleam_stdlib
d:/home/fw/projects/hello/build/dev/erlang/gleam_stdlib/_gleam_artefacts/gleam@float.erl:166:21: Warning: this clause cannot match because a previous clause at line 165 always matches
% 166| -0.0 -> -0.0;
% | ^
Compiling gleeunit
Compiling floki
error: File IO failure
An error occurred while trying to link this file:
D:\home\fw\projects\hello\build\dev\erlang\eex
The error message from the file IO library was:
厢ćˇçŤŻć˛Ąććéççšćă (os error 1314)
~/projects/hello $ ~\projects\gleam\target\release\gleam.exe run
Compiling floki
error: File IO failure
An error occurred while trying to link this file:
D:\home\fw\projects\hello\build\dev\erlang\eex
The error message from the file IO library was:
厢ćˇçŤŻć˛Ąććéççšćă (os error 1314)
~/projects/hello $ ~\projects\gleam\target\release\gleam.exe run
Compiling floki
error: File IO failure
An error occurred while trying to link this file:
D:\home\fw\projects\hello\build\dev\erlang\eex
The error message from the file IO library was:
厢ćˇçŤŻć˛Ąććéççšćă (os error 1314)
~/projects/hello $
Thank you
gleam add finch_gleam
import finch
gleam run
result:exception error: no match of right hand side value {error,{elixir,{"no such file or directory","elixir.app"}}}
elixir --version
result:gleam --version
result:gleam 0.31.0