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

Error handling excludes from parent gitignore files prevents publishing #4300

Closed
jakemac53 opened this issue Jun 5, 2024 · 3 comments
Closed

Comments

@jakemac53
Copy link
Contributor

jakemac53 commented Jun 5, 2024

Problem

This came up when @elliette was trying to publish the dap package, which lives under https://github.com/dart-lang/sdk/tree/main/third_party/pkg/dap.

There is a .gitignore file two directories above this, which ignores everything under third_party except some specifically listed directories, including this one (see here).

When trying to publish, pub gives an error that the files in the package are git ignored, and won't be published.

Error logs

Validating package... (1.5s)
Package validation found the following errors:

  • The pubspec is hidden, probably by .gitignore or pubignore.

  • You must have a LICENSE file in the root directory.
    An open-source license helps ensure people can legally use your code.
    Package validation found the following potential issues:

  • 17 checked-in files are ignored by a .gitignore.
    Previous versions of Pub would include those in the published package.

    Consider adjusting your .gitignore files to not ignore those files, and if you do not wish to
    publish these files use .pubignore. See also dart.dev/go/pubignore

    Files that are checked in while gitignored:

    CHANGELOG.md
    LICENSE
    OWNERS
    README.md
    analysis_options.yaml
    lib/dap.dart
    lib/src/exceptions.dart
    lib/src/protocol_common.dart
    lib/src/protocol_generated.dart
    lib/src/protocol_special.dart

Expected behavior

Should be able to publish, the directory is not actually ignored.

Actual behavior

Can't publish, and if we could it seems that several of the required files would not be published.

@sigurdm
Copy link
Contributor

sigurdm commented Jun 10, 2024

I believe he warning is actually correct. third_party/pkg/dap is actually ignored by the gitignore.

The reason you see pkg/dap as not ignored by git is because it is checked in despite being ignored. We have decided that this is an inconsistency, and pub will not publish such a file, but warn about its existence.

Even though it looks like the third_party/pkg/dap folder is excluded in the .gitignore, it is not. This has to do with how gitignores are implemented (both by git and pub):

Directories are matched before their content recursively. And if a directory is ignored, its content is not examined at all. pkg/ is ignored by the * pattern, so we never get to examine pkg/dap and its contents.

To truly except pkg/dap from being ignored you need to first exclude pkg/ from the ignore, then reignore all its contents and then exclude the pkg/dap folder againg. See https://stackoverflow.com/a/11018557

Try something like:

# ignore everything
/* # < -- note the leading slash, this anchors this to exclude only folders at root.
# except for the following files and directories:
!.gitignore
!binaryen
!d8
!firefox_jsshell
!clang.tar.gz.sha1
!unittest.tar.gz.sha1
!update.sh
!/wasmer
!/pkg/ # < --- new
/pkg/* # < --- new
!/pkg/native_assets_builder.status
!/pkg/native_assets_cli.status
!/pkg/native_toolchain_c.status
!/pkg/dap/*
!/pkg/language_server_protocol/
!fallback_root_certificates

@jakemac53
Copy link
Contributor Author

cc @elliette can you try those suggestions?

@elliette
Copy link

Thank you! That almost worked! I added one more line to get it fully working:

# ignore everything
/*
# except for the following files and directories:
!.gitignore
!binaryen
!d8
!firefox_jsshell
!clang.tar.gz.sha1
!unittest.tar.gz.sha1
!update.sh
!/wasmer
!/pkg/
/pkg/*
!/pkg/native_assets_builder.status
!/pkg/native_assets_cli.status
!/pkg/native_toolchain_c.status
!/pkg/dap # <----- ADDED THIS LINE TOO
!/pkg/dap/*
!/pkg/language_server_protocol/
!fallback_root_certificates

I'm going to open up a CL with those changes. Closing this now.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jun 11, 2024
…ring publishing.

Bug: dart-lang/pub#4300
Change-Id: I0679d5425b90d454e6f2bd7e0de9d0aac9e84581
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370700
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
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

No branches or pull requests

3 participants