bazel-contrib / bazel-gazelle

Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.19k stars 378 forks source link

Gazelle no such file or directory (windows 11) #1874

Closed brounnoupegreula-7757 closed 1 month ago

brounnoupegreula-7757 commented 1 month ago

What version of gazelle are you using?

0.38.0

What version of rules_go are you using?

0.49.0

What version of Bazel are you using?

7.3.0

Does this issue reproduce with the latest releases of all the above?

yes

What operating system and processor architecture are you using?

windows 11

What did you do?

i try bazel gazelle with bzlmod :

MODULE.bazel

bazel_dep(name = "rules_go", version = "0.49.0")
bazel_dep(name = "gazelle", version = "0.38.0")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.22.6")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "com_github_gofiber_fiber_v3")

BUILD.bazel

load("@gazelle//:def.bzl", "gazelle")

gazelle(name = "gazelle")

and run with this command :

bazel run //:gazelle

image

i got error like above command gazelle not found, i run inside terminal goland but when i try to check the directory the app is exist

image

look like the the command running inside linux bash but not running /mnt

how can i fix it?

fmeum commented 1 month ago

Could you post the content of the gazelle-runner.bash file in that directory?

Are you using MSYS2 to provide bash?

brounnoupegreula-7757 commented 1 month ago
#!/usr/bin/env bash

# Copyright 2017 The Bazel Authors. All rights reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#    http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# --- begin runfiles.bash initialization v3 ---
# Copy-pasted from the Bazel Bash runfiles library v3.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
  source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
  source "$0.runfiles/$f" 2>/dev/null || \
  source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
  source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
  { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v3 ---

# Generated by @@//:gazelle-runner
# DO NOT EDIT

set -euo pipefail

GAZELLE_PATH='gazelle~/cmd/gazelle/gazelle_/gazelle.exe'
ARGS=('update' '-bzlmod')
GOTOOL='rules_go~~go_sdk~go.brimola.bri.co.id__download_0/bin/go.exe'
REPO_CONFIG_PATH='gazelle~~go_deps~bazel_gazelle_go_repository_config/WORKSPACE'
WORKSPACE=""

# set_goroot attempts to set GOROOT to the SDK used by rules_go. gazelle
# invokes tools inside the Go SDK for dependency management. It's good to
# use the SDK used by the workspace in case the Go SDK is not installed
# on the host system or is a different version.
function set_goroot {
  local gotool
  gotool=$(rlocation "$GOTOOL")
  if [ -z "$gotool" ]; then
    echo "$0: warning: could not locate GOROOT used by rules_go" >&2
    return
  fi
  GOROOT=$(cd "$(dirname "$gotool")/.."; pwd)
  export GOROOT
  if type cygpath >/dev/null 2>&1; then
    # On Windows, convert the path to something usable outside of bash.
    GOROOT=$(cygpath -w "$GOROOT")
  fi
}

# If arguments were provided on the command line, either replace or augment
# the generated args.
case "${1-}" in
  "fix" | "update" | "help" | "update-repos")
    ARGS=("$@")
    ;;
  *)
    ARGS+=("$@")
    ;;
esac

# Invoke Gazelle.
# Note that we don't change directories first; if we did, Gazelle wouldn't be
# able to find runfiles, and some extensions rely on that. Gazelle can use
# BUILD_WORKSPACE_DIRECTORY to interpret relative paths on the command line.
set_goroot
gazelle_path=$(rlocation "$GAZELLE_PATH")
if [ -z "$gazelle_path" ]; then
  echo "error: could not locate gazelle binary" >&2
  exit 1
fi
if [[ -n "${TEST_WORKSPACE+x}" && -n "$WORKSPACE" ]]; then
  BUILD_WORKSPACE_DIRECTORY="$(dirname "$(readlink ${WORKSPACE})")"
  export BUILD_WORKSPACE_DIRECTORY
fi
if [ -z "${BUILD_WORKSPACE_DIRECTORY-}" ]; then
  echo "error: BUILD_WORKSPACE_DIRECTORY not set" >&2
  exit 1
fi

# Determine if we are running the fix/update command
if [[ ${#ARGS[@]} -gt 0 ]]; then
  case "${ARGS[0]}" in
    "fix" | "update")
      is_fix_or_update="true"
      ;;
    *)
      is_fix_or_update="false"
      ;;
  esac
fi

# When running with Bzlmod, there is no WORKSPACE file for Gazelle to read
# the definitions of go_repository rules from. Instead, we pass the path to
# the repo config file as a flag.
if [[ "${is_fix_or_update:-}" == "true"  ]] && [[ -n $REPO_CONFIG_PATH ]]; then
  ARGS=("${ARGS[0]}" "-repo_config" "$(rlocation "$REPO_CONFIG_PATH")" "${ARGS[@]:1}")
fi

runfiles_export_envvars
"$gazelle_path" "${ARGS[@]}"

this is @fmeum

no i am using wsl linux windows 11 @fmeum

brounnoupegreula-7757 commented 1 month ago

i fix it @fmeum

gazelle not working with wsl, so i change to git bash and it worked