Skip to content

pleasew build error #3199

Closed
Closed

Description

@Jwinf

I wrote an sh_binary in a BUILD.plz file, and when I ran the "./pleasew build " command, it threw an error: "error: name 'sh_library' is not defined". How can I solve it?
Snipaste_2024-07-20_16-32-19
Snipaste_2024-07-20_16-33-01

Activity

  1. cemeceme commented on Jul 20, 2024

    @cemeceme
    Contributor

    It appears that you have not added the shell plugin to your project, so the sh_binary and related rules are not defined.

    TLDR: run plz init plugin shell

    This should set everything up for you. Alternatively, you can do what it does manually, if you want more control.

    Essentially, you need to create a BUILD file, that defines each plugin you wish to use in your project. The init command creates a plugins/BUILD file, although you can change this as long as you edit your .plzconfig to suit.
    In your case, to this file, you would add

    plugin_repo(
      name = "shell",
      revision = "v0.2.0",
      plugin = "shell-rules",
      owner = "please-build",
    )
    

    See https://github.com/please-build for the list of options of other plugins that are offered by the please devs. Of course, you can also use rules that other people have made as well, where the owner is the username, plugin is the repo name, revision is the branch or release name and name is the name you want to locally refer to the plugin as.

    Finally, you will need to edit your .plzconfig file to add the lines

    [parse]
    preloadsubincludes = ///shell//build_defs:shell
    
    [Plugin "shell"]
    Target = //plugins:shell
    

    Here, the Target= line defines where to find the plugin definition, formatted as a please file path. If you place your plugin rules somewhere else, you will need to adjust this line.
    The preloadsubincludes= line is optional, but if you leave this out, you will have to add subinclude("///shell//build_defs:shell") to every file that uses the shell rules. Sometimes this is useful if you have name clashes between different plugins.

  2. locked and limited conversation to collaborators on Sep 18, 2024
  3. converted this issue into a discussion #3258 on Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions