Submitting path is case sensitive

I would like to ask for a feature change on the cli for exercism submit PATH to be case insensitive.

eg.

submitting path:

$HOME/USERNAME/exercism/go/hello-world/hello_world.go

Result:

Error:

    You are submitting a directory, which is not currently supported.

Expected result:

    Your solution has been submitted successfully.
    View it at:


    https://exercism.org/tracks/go/exercises/hello-world

Troubleshooting Information

Version

Current: 3.5.1
Latest: 3.5.1

Operating System

OS: darwin
Architecture: arm64

Configuration

Home: /Users/USERNAME
Workspace: /Users/USERNAME/Exercism
Config: /Users/USERNAME/.config/exercism
API key: 8a5d*****************************715

API Reachability

GitHub:
* api.github_com
* [connected]
* 42.128625ms

Exercism:
* https://api.exercism.io/v1/ping
* [connected]
* 292.617041ms

If you are having trouble, please create a new topic in the Exercism forum
at forum_exercism_org/c/support/cli/10 and include
this information.

On some operating systems, path names are case sensitive. $HOME/foo and $HOME/FOO are different paths and can co-exist. Blindly making paths insensitive is incorrect.

That error suggests you passed a directory and not a file.

$HOME will already be /Users/USERNAME, so $HOME/USERNAME/... is probably not a directory.

If your current directory is ~/Exercism/go/hello-world then you can simply

exercism submit

The CLI knows what file it needs to send.

for instance i created the folder /Users/USERNAME/exercism/go

I used ran the cli to submit:

exercism submit $(pwd)/hello_world.go

or

exercism submit $HOME/hello_world.go

the command returned the above error. I think this is wrong because i passed the path to the file, and even if i typed the path it returned an error. This should not be the error returned. If i created the folder prior to downloading the exercise it should prompt the user to update the path name since it is case sensitive when it downloads, or utilize the path to the file and submit the go file passed.

Error:

Error:

    You are submitting a directory, which is not currently supported.

        /Users/USERNAME/exercism/go/lasagna/hello_world.go

    Please change into the directory and provide the path to the file(s) you wish to submit

        exercism submit FILENAME

Running:
exercism submit $(pwd)/hello_world.go

Error: 
not in workspace: directory location may be case sensitive: 

workspace directory: /Users/USERNAME/Exercism, 

submit path: /Users/USERNAME/exercism/go/hello-world/hello_world.go

To me this seems like exercism should be able to run path agnostic and should not be case sensitive, but instead should run from any path given.

Try one of these:

  • exercism submit hello_world.go
  • exercism submit

Exercism isn’t case sensitive. File systems are case sensitive.

Does your $HOME or $(pwd) contain spaces? That might explain why the cli thinks it’s a directory.

Can you post the result of running:

stat "$HOME/hello_world.go"

This could help us debug if there’s something that can be changed in the CLI. I quickly checked the CLI code, and it’s indeed throwing that error when the path is a directory, so the code seems correct.

I can’t reproduce your error. I can pass a path to a file to the cli directly, and when I pass a directory I do get the directory error as expected:

$ exercism submit $HOME/Exercism/andrerfcsantos-exercism/go/hello-world
Error:

    You are submitting a directory, which is not currently supported.

        /Users/andre.santos/Exercism/andrerfcsantos-exercism/go/hello-world

    Please change into the directory and provide the path to the file(s) you wish to submit

        exercism submit FILENAME


$ exercism submit $HOME/Exercism/andrerfcsantos-exercism/go/hello-world/hello_world.go


    Your solution has been submitted successfully.
    View it at:


    https://exercism.org/tracks/go/exercises/hello-world

So, this seems to confirm the CLI is correctly identifying a directory vs file.

More information on the specific path could help us try to reproduce what you are saying:

  • Does it have spaces or any special characters?
  • What’s the result of stat $HOME/hello_world.go?

It seems that the workspace directory for the cli is configured to be /Users/USERNAME/Exercism, but you are working in /Users/USERNAME/exercism, which are two different folders. It’s not up to the CLI to try to treat these as equal. If the filesystem/operating system treats them differently, the CLI should honor that too.

If all your stuff for Exercism is in /Users/USERNAME/exercism, maybe you can make that your workspace? You can change your workspace with:

exercism config -w "/Users/USERNAME/exercism"

In any case, to submit your solutions despite all of these issues, you can run exercism submit with no arguments or exercism submit <solution_file1> [solution_file2] inside the exercise directory like others suggested before.

/Users/username indicates this is probably macOS, where the filesystem DOES handle paths insensitively. But the CLI is coded in Go and that would probably use case-sensitivity.

Go ultimately does syscalls for the operations that touch the files. The logic to check if the path exists and is a directory is using stat, which is also a syscall.

I did a quick sample Go program to test doing a stat and opening a file, both with a path where “Exercism” is uppercased and lowercased. I used the same Stat version the CLI is using, and the lowercase path doesn’t “really” exist on my system. Here’s the findings:

  1. Stat was able to return information for both paths, and didn’t give any error.
  2. Stat was able to confirm that none of the paths were a directory
  3. Go could open the file fine when given both versions of the path

Point 2 makes me think the issue is something with the specific path and not a case-sensitivity issue, because:

  1. In the CLI, we are only checking if the path is a directory if stat is successful. If we see the message complaining about the path being a directory, this means stat was able to recognize the path as existing and being valid, but it thinks it’s a directory and not a file.
  2. In my testing, I wasn’t able to reproduce the fact that /Users/USERNAME/exercism/go/lasagna/hello_world.go was being recognized as a directory like @codedlearns is reporting. Even in the lowercase version of the path which doesn’t really exist, Go was able to tell this is a file and could stat it just fine.
2 Likes