@@ -6,14 +6,14 @@ module Travis
       class EnsurePathComponents < Base
 
         COMPONENTS = [
-          '$(yarn global bin)'
+          '$(yarn global bin | grep /)'
         ]
 
         def apply
           COMPONENTS.each do |pc|
             sh.cmd <<-EOF
 pc=#{pc}
-if [[ -z $(echo :$PATH: | grep :$pc:) ]]; then export PATH=$PATH:$pc; fi
+if [[ -n $pc && -z $(echo :$PATH: | grep :$pc:) ]]; then export PATH=$PATH:$pc; fi
 unset pc
             EOF
           end
require 'travis/build/appliances/base'

module Travis
  module Build
    module Appliances
      class EnsurePathComponents < Base

        COMPONENTS = [
          '$(yarn global bin)'
        ]

        def apply
          COMPONENTS.each do |pc|
            sh.cmd <<-EOF
pc=#{pc}
if [[ -z $(echo :$PATH: | grep :$pc:) ]]; then export PATH=$PATH:$pc; fi
unset pc
            EOF
          end
        end
      end
    end
  end
end

This grep might leak into the build log. Wouldn't `=~` work as a shell test?