gleam won't let me create a project with non utf8 name but i can create a project in a directory where one of the path segments is non-utf8.
eg:
mkdir $'\xC0\xC0'
cd $'\xC0\xC0'
gleam new samplegleam
cd simplegleam
however this is NOT the intended behavior beause when i run any command, like gleam build or gleam run etc... they all fail.
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
and include this error message with your report.
Panic: compiler-cli/src/main.rs:558
Failed to get current directory: NonUtf8Path { path: "/home/zahash/source/\xC0\xC0/samplegleam" }
Gleam version: 1.0.0
Operating system: linux
If you can also share your code and say what file you were editing or any
steps to reproduce the crash that would be a great help.
You may also want to try again with the `GLEAM_LOG=trace` environment
variable set.
the problem is because when i do gleam new samplegleam, the NewOptions.project_root: String is set to "simplegleam". and the Creator::new function makes a Utf8PathBuf with just the "simplegleam" string and doesn't check its full path /home/zahash/source/��/samplegleam
the root cause of this is the improper path checking when a new instance of Utf8PathBuf is created from a String. it assumes that since the Utf8PathBuf is created from a String it must be valid utf8. But it fails to consider that the String might be just a relative path. The absolute path might contain non-utf8 segments.
the reason why gleam run and gleam clean catch this error is because they use find_project_paths function which uses get_current_directory which uses std::env::current_dir() which gives the absolute path of the current directory. So, when it is converted to Utf8PathBuf, it fails.
gleam won't let me create a project with non utf8 name but i can create a project in a directory where one of the path segments is non-utf8.
eg:
however this is NOT the intended behavior beause when i run any command, like
gleam build
orgleam run
etc... they all fail.the problem is because when i do
gleam new samplegleam
, theNewOptions.project_root: String
is set to "simplegleam". and theCreator::new
function makes aUtf8PathBuf
with just the "simplegleam" string and doesn't check its full path/home/zahash/source/��/samplegleam
the root cause of this is the improper path checking when a new instance of
Utf8PathBuf
is created from aString
. it assumes that since theUtf8PathBuf
is created from aString
it must be valid utf8. But it fails to consider that theString
might be just a relative path. The absolute path might contain non-utf8 segments.the reason why
gleam run
andgleam clean
catch this error is because they usefind_project_paths
function which usesget_current_directory
which usesstd::env::current_dir()
which gives the absolute path of the current directory. So, when it is converted toUtf8PathBuf
, it fails.but the
gleam new
command uses a different function as mentioned above