59

I am trying to install fastlane. I have Xcode installed. I installed fastlane using the command sudo gem install fastlane. I now go into my project folder and type fastlane init and get the error:

-bash: fastlane: command not found.

I see that fastlane is installed and can see it here

/Users/username/.gem/ruby/2.0.0/gems/fastlane-1.70.0/bin

on my Mac.

I tried adding this to my PATH, but I still get the same error. My path is

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:./Users/username/.gem/ruby/2.0.0/gems/

What am I missing here?

Unheilig
  • 16,196
  • 193
  • 68
  • 98
  • 1
    Did you reopen the terminal after the installation? Maybe try to `source ~/.bash_profile`. If there's still problem, add `/Users/username/.gem/ruby/2.0.0/gems/fastlane-1.70.0/bin` to your PATH. – J.Wang Apr 05 '16 at 00:25
  • 1
    Wow. This solved the issue. Thanks much Wang. I have tried adding /Users/username/.gem/ruby/2.0.0/gems/fastlane-1.70.0 this to my PATH earlier and it never worked before. Thanks for this fix buddy. Saved me a ton of time. Wish I could make this the accepted answer – Viswanth Chadalawada Apr 09 '16 at 13:24
  • 1
    Keep in mind that if you include a path like /Users/username/.gem/ruby/2.0.0/gems/fastlane-1.70.0 in your PATH, you will have to remember to change that each time you update fastlane to a new version. Ruby should be managing the process of making gem-provided commands available, so I would seek out a solution that fixes your Ruby setup. – Mike Furtak Mar 24 '17 at 16:56

17 Answers17

55

Add the following line to your bash profile:

export PATH="$HOME/.fastlane/bin:$PATH"

You can either close the terminal session and restart it or run source ~/.bash_profile to load your configuration and then you can go so you start using fastlane

Bonifacio2
  • 3,405
  • 6
  • 34
  • 54
baichao zeng
  • 551
  • 4
  • 2
46

I got run into similar issue last week. I installed fastlane using homebrew on mac, but it was showing the same error.

I tried installing it using Ruby and it worked like a charm. Here is the command.

sudo gem install fastlane -NV

Also seems like you have not installed command line tools for xcode.

Install them using xcode-select --install

Bonifacio2
  • 3,405
  • 6
  • 34
  • 54
atitpatel
  • 3,104
  • 1
  • 24
  • 34
25

I met this issue because of installing zsh, the below two steps solve my problem:

  1. open ~/.zshrc
  2. save path

    2.1 if you install fastlane with Homebrew

    Copy export PATH="$HOME/.fastlane/bin:$PATH" on the bottom line.

    2.2 if you install fastlane with RubyGems

    Copy export PATH="/usr/local/bin/fastlane"" on the bottom line.

  3. save upon file and try fastlane init, everything is OK!

mistdon
  • 1,773
  • 16
  • 14
17
  1. In the terminal type cd ~/ to go to your home folder
  2. Type touch .bash_profile to create your new empty file
  3. Type open -e .bash_profile to open the file
  4. Enter export PATH="$HOME/.fastlane/bin:$PATH" and save
  5. Restart terminal (not sure needed?)
Sunkas
  • 9,542
  • 6
  • 62
  • 102
12

Here is what I installed on Mac - from scratch

Removed from brew install

brew uninstall fastlane

brew install rbenv

Install Ruby version 2.6.6

rbenv install 2.6.6

Set the Ruby version in global

rbenv global 2.6.6

Add Ruby to the PATH

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

Install bundler

gem install bundler

Install fastlane

bundle add fastlane

Jijo John
  • 1,368
  • 2
  • 17
  • 31
8

fastlane is in cask now. You can install it using

brew cask install fastlane

Now you need to export PATH so that your shell can find fastlane do

export PATH="$HOME/.fastlane/bin:$PATH"

If that doesn't work, try this

export PATH="$HOME/.fastlane/bin/fastlane_lib:$PATH"

Make sure you add it to ~/.profile, ~/.zshrc or ~/.bashrc for future

sudo bangbang
  • 27,127
  • 11
  • 75
  • 77
6

If you are working on local machine then add following to you .bash_profile

export PATH="$HOME/.fastlane/bin:$PATH"

If you are working on Jenkins then this worked for me

Under Jenkins -> Manage Jenkins -> Configure System -> Global properties -> Environment variables I added:

Name: Path Value: /bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Reference

Sishu
  • 1,510
  • 1
  • 21
  • 48
6

brew install ruby

brew install fastlane

Warning: fastlane 2.145.0 is already installed, it's just not linked You can use brew link fastlane to link this version.

brew link fastlane

cd iOS

fastlane init

Amit
  • 2,389
  • 22
  • 29
4

I have got the same issue on mac 10.11, after a lot of struggling I found that the problem in installing unf_ext 0.0.7.2 gem I have done the following from this answer

brew install coreutils

After that try reinstall fastlane again it should work again

Community
  • 1
  • 1
Mohamed Saleh
  • 2,881
  • 1
  • 23
  • 35
2

I faced this issue in Fedora 30 i followed these steps:-

1-installed all dev tools using these commands

sudo dnf install @development-tools
sudo dnf install @rpm-development-tools

2- run sudo gem install fastlane -NV

Fastlane worked like a charm hope it helped

2

I managed to install following way

Install ruby

sudo apt install ruby ruby-dev

Add following to top of your "~/.profile" file

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Check of any errors with source ~/.profile command. If there is not output means all is good.

Install Build essentials

sudo apt-get update
sudo apt-get install build-essential

Fastlane depends on Google API Clint lets install that first

sudo gem install google-api-client

Install Fastlane

sudo gem install fastlane -NV

Check your installation

fastlane -v

Output Should be like

Credits: This and this article helped me.

Owais
  • 482
  • 4
  • 5
  • thanks for your answer I tried it but getting ERROR: Error installing fastlane: ERROR: Failed to build gem native extension. current directory: /root/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/unf_ext-0.0.8.2/ext/unf_ext /root/.rbenv/versions/2.7.2/bin/ruby -I /root/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20220913-859-1mzlwgp.rb extconf.rb extconf failed, exit code 1 – Maveňツ Sep 14 '22 at 06:05
2

Flutter and Github Actions for Android:

If you are setting up Github Actions for a Flutter project for android and run into this error in one of your steps, see the work flow below:

jobs:
  release:
    runs-on: ubuntu-latest
    env:
      LC_ALL: en_US.UTF-8
      LANG: en_US.UTF-8
    steps:
      - uses: actions/checkout@v3

      - name: Set up ruby
        uses: ruby/setup-ruby@v1

      - name: Setup Fastlane
        working-directory: ./android  # <-- Make sure you have this
        run: bundle install

      - name: Run Fastlane
        working-directory: ./android. # <-- Make sure you have this
        run: bundle exec fastlane android [lane name].

Make sure to setup the ruby/setup-ruby@v1 action correctly depending on your project. see the doc: https://github.com/ruby/setup-ruby

In my case I have not specified the ruby version because I am using the .ruby-version file in my project.

Margach Chris
  • 1,404
  • 12
  • 20
1

DO NOT INSTALL FASTLANE GLOBALLY It is recommended that you use a Gemfile to define your dependency on Fastlane. This will clearly define the used Fastlane version, and its dependencies, and will also speed up using Fastlane.

Step 1: Install bundler using

sudo gem install bundler

so any time you wan run Fastlane
bundler exec fastlane ...

Mohamed Elmi Hassan
  • 321
  • 1
  • 3
  • 12
1

You can add fastlane path environment by add line

export PATH="$HOME/.fastlane/bin:$PATH"

to ~/.bash_profile or ~/.zsh_profile file (if you use zsh shell).

And final start new terminal session or reload using command source ~/.bash_profile or source ~/.zsh_profile (if you use zsh shell)

Thanh Vu
  • 1,599
  • 10
  • 14
1

First,You need to check if you have the ~/.fastlane file. If you don't have the file, you can execute brew cask install fastlane command. If you already have it. Check other answers.

littlebear333
  • 710
  • 2
  • 6
  • 14
0

Im my case, I need to add this path to my env, then command is found.

export PATH="/opt/homebrew/lib/ruby/gems/3.2.0/gems/fastlane-2.214.0/bin:$PATH"

Try reinstall fastlane, it didn't create .fastlane in my $HOME dir.

RubyGems Environment:
  - RUBYGEMS VERSION: 3.4.2
  - RUBY VERSION: 3.2.0 (2022-12-25 patchlevel 0) [arm64-darwin21]
  - INSTALLATION DIRECTORY: /opt/homebrew/lib/ruby/gems/3.2.0
  - USER INSTALLATION DIRECTORY: /Users/haibozhou/.gem/ruby/3.2.0
  - RUBY EXECUTABLE: /opt/homebrew/opt/ruby/bin/ruby
  - GIT EXECUTABLE: /opt/homebrew/bin/git
  - EXECUTABLE DIRECTORY: /opt/homebrew/lib/ruby/gems/3.2.0/bin
  - SPEC CACHE DIRECTORY: /Users/haibozhou/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /opt/homebrew/Cellar/ruby/3.2.0/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - arm64-darwin-21
  - GEM PATHS:
     - /opt/homebrew/lib/ruby/gems/3.2.0
     - /Users/haibozhou/.gem/ruby/3.2.0
     - /opt/homebrew/Cellar/ruby/3.2.0/lib/ruby/gems/3.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => true
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /opt/homebrew/lib/ruby/gems/3.2.0/gems/fastlane-2.214.0/bin
     - /Users/haibozhou/.gem/ruby/3.2.0/bin
     - /opt/homebrew/opt/ruby/bin
     - /opt/homebrew/opt/openjdk@11/bin
     - /opt/homebrew/bin
     - /opt/homebrew/sbin
Zhou Haibo
  • 1,681
  • 1
  • 12
  • 32
-6

Get the full path of the fastlane executable from the command line:

which fastlane

Add it to the shell profile, restart shell.

val
  • 129
  • 1
  • 5