nim-lang / nimble

Package manager for the Nim programming language.
Other
1.24k stars 174 forks source link

nimble script incuded files inconsistent use with cache #1178

Open ggb-sw opened 5 months ago

ggb-sw commented 5 months ago

Initial test:

# file: test1.nimble

include nimble_includes

version       = "0.1.0"
author        = "Me"
description   = "Test for nimble"
license       = "MIT"

# Dependencies

requires "nim >= 2.0.0"
# File: nimble_includes.nim

task test1, "First test for nimble":
  echo "Author: ", author
  echo "Description: ", description
  echo "project: ", projectName()

Now run nimble test1

Result is:

   Warning: Package 'test1' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'test1.nim', but a file named 'nimble_includes.nim' was found. This will be an error in the future.
      Hint: If this is the primary source file in the package, rename it to 'test1.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'test1', then move it into a 'test1/' subdirectory. If it's a test file or otherwise not required to build the the package 'test1.nim', prevent its installation by adding `skipFiles = @["nimble_includes.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
  Verifying dependencies for test1@0.1.0
  Executing task test1 in /home/ggb/Temp/nim/test1/test1.nimble
Author: 
Description: 
project: test1

This works, to a degree, but does not show a description or author because the include statement is before the assignment of author and description, so I change that:

# file: test1.nimble

version       = "0.1.0"
author        = "Me"
description   = "Test for nimble"
license       = "MIT"

include nimble_includes

# Dependencies

requires "nim >= 2.0.0"

The output seems reasonable:

   Warning: Package 'test1' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'test1.nim', but a file named 'nimble_includes.nim' was found. This will be an error in the future.
      Hint: If this is the primary source file in the package, rename it to 'test1.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'test1', then move it into a 'test1/' subdirectory. If it's a test file or otherwise not required to build the the package 'test1.nim', prevent its installation by adding `skipFiles = @["nimble_includes.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
  Verifying dependencies for test1@0.1.0
  Executing task test1 in /home/ggb/Temp/nim/test1/test1.nimble
Author: Me
Description: Test for nimble
project: test1

But it seems to work because the task test1 has been cached.

When I change the task name to test2 so as to invalidate the cache:

# File: nimble_includes.nim

task test2, "First test for nimble":
  echo "Author: ", author
  echo "Description: ", description
  echo "project: ", projectName()

And now run nimble test2

I now receive the error:

   Warning: Package 'test1' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'test1.nim', but a file named 'nimble_includes.nim' was found. This will be an error in the future.
      Hint: If this is the primary source file in the package, rename it to 'test1.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'test1', then move it into a 'test1/' subdirectory. If it's a test file or otherwise not required to build the the package 'test1.nim', prevent its installation by adding `skipFiles = @["nimble_includes.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
       Tip: 1 messages have been suppressed, use --verbose to show them.
nimble.nim(2130)         doAction

    Error:  Could not find task test2 in /home/ggb/Temp/nim/test1/test1.nimble
     Hint:  Run `nimble --help` and/or `nimble tasks` for a list of possible commands.