RoR na iMacu

Cześć wam, od niedawna mam okazję popracować na iMacu, więc postanowiłem zgłębić tajemnice RoR’a.
I utknąłem na samym początku, nie potrafię zaktualizować railsów do najnowszej wersji. Czy ktoś zna jakiś sposób?

iMac-Piotr:~ piotr$ rails -v Rails 2.3.5 iMac-Piotr:~ piotr$ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
a gdy próbuje rails update mam taki wynik:

iMac-Piotr:~ piotr$ rails update /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:55:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support.rb:56 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:55:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/bin/../lib/rails_generator.rb:28 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:55:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/bin/rails:14 from /usr/bin/rails:19:in `load' from /usr/bin/rails:19
Z góry dzięki


potem zainstaluj sobie Rails:

gem install rails

być może będziesz potrzebował gcc, żeby skompilować ruby.
Ostatnio nie trzeba do tego instalować całego Xcode:
https://github.com/kennethreitz/osx-gcc-installer

Zainstalowalem GGC a przy próbie gem install rails:

iMac-Piotr:~ piotr$ gem install rails ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /Library/Ruby/Gems/1.8/gems/json-1.6.1/tests/test_json_string_matching.rb

najpierw zainstaluj rvm - @sevos podał Ci linka.

Tak właśnie próbuje, jednak gdy wpisuje:

curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer

mam taki oto wynik:

[code]binscripts/rvm-installer
#!/usr/bin/env bash

shopt -s extglob
PS4="+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > "
export PS4
set -o errtrace
set -o errexit

log() { printf “$*\n” ; return $? ; }

fail() { log “\nERROR: $*\n” ; exit 1 ; }

usage()
{
printf "

Usage

rvm-installer [options] [action]

Options

–branch - Install RVM head, from named branch
–version <head|latest|x.y.z> - Install RVM version [head|latest|x.y.z]
–trace - used to debug the installer script

Actions

help - Display CLI help (this output)

"
}

fetch_version()
{
version=$(curl -s -B “${rvm_releases_url}/latest-version.txt” 2>/dev/null)
}

fetch_md5()
{
md5=$(curl -s -B “${rvm_releases_url}/rvm-${version}.tar.gz.md5” 2>/dev/null)
}

md5_match()
{
local archive="$1"

case “$(uname)” in
Darwin|FreeBSD)
archive_md5="$(/sbin/md5 -q “${archive}”)"
;;

OpenBSD)
  archive_md5="$(/bin/md5 -q "${archive}")"
  ;;

Linux|*)
  archive_md5="$(md5sum "${archive}")"
  archive_md5="${archive_md5%% *}"
  ;;

esac

if [[ “$archive_md5” == “$md5” ]]
then
return 0
else
return 1
fi
}

install_release()
{
local archive url

archive="${rvm_archives_path}/rvm-${version}.tar.gz"
url="${rvm_releases_url}/rvm-${version}.tar.gz"

fetch_md5

if [[ -s “${archive}” && -n “${md5}” ]] && ! md5_match “${archive}”
then
# Remove old installs, if they exist and have incorrect md5.
if [[ -f “${archive}” ]]
then
rm -f “${archive}”
fi
fi

if curl -L “${url}” -o “${archive}”
then
true
else
fail “Failed to download ${url} to ${archive} using ‘curl’, error code ($?)”
fi

if ! md5_match “$archive”
then
fail "ERROR:

Archive package downloaded does not match its calculated md5 checksum ${md5}:

$rvm_archives_path/rvm-${version}.tar.gz

Retry the installation and/or check your networking setup.

Halting installation.
"
fi

if tar zxf “${archive}” -C “$rvm_src_path/” --no-same-owner
then
cd “$rvm_src_path/rvm-${version}”
else
fail “Failed to extract ${archive} to ${rvm_src_path}/,”
“tar command returned error code $?”
fi
}

install_head()
{
local remote=“origin”

if [[ -d “${rvm_src_path}/rvm/.git” ]]
then
builtin cd “${rvm_src_path}/rvm/”

if [[ -z "$(git branch | awk "/$branch$/")" ]]
then
  if git checkout -b "$branch" --track "$remote/$branch" 2>/dev/null
  then
    log "Successfully checked out branch '$branch'"
  else
    fail "$remote $branch remote branch not found."
  fi
elif [[ -z "$(git branch | awk "/\* $branch$/{print \$2}")" ]]
then
  if git checkout $branch 2>/dev/null
  then
    log "Successfully checked out branch '$branch'"
  else
    fail "Unable to checkout branch $branch."
  fi
fi

if git pull --rebase $remote $branch
then
  log "Successfully pulled (rebased) from $remote $branch"
else
  fail "Failed pull/rebase $remote $branch"
fi

else
builtin cd “${rvm_src_path}”

if ! git clone --depth 1 git://github.com/wayneeseguin/rvm.git
then
  if !  git clone https://github.com/wayneeseguin/rvm.git
  then
    fail "Unable to clone the RVM repository, attempted both git:// and https://"
  fi
fi

fi

builtin cd “${rvm_src_path}/rvm/”

return 0
}

Tracing, if asked for.

if [[ “$*” =~ --trace ]] || (( ${rvm_trace_flag:-0} > 0 ))
then
set -o xtrace
export rvm_trace_flag=1
fi

Variable initialization, remove trailing slashes if they exist on HOME

true
${rvm_trace_flag:=0} ${rvm_debug_flag:=0} ${rvm_user_install_flag:=0}
${rvm_ignore_rvmrc:=0} HOME="${HOME%%+(/)}"

if (( rvm_ignore_rvmrc == 0 ))
then
for rvmrc in /etc/rvmrc “$HOME/.rvmrc”
do
if [[ -s “$rvmrc” ]]
then
if \grep ‘^\srvm .$’ “$rvmrc” >/dev/null 2>&1
then
printf “\nError: $rvmrc is for rvm settings only.\n”
printf “rvm CLI may NOT be called from within $rvmrc. \n”
printf “Skipping the loading of $rvmrc\n”
return 1
else
source “$rvmrc”
fi
fi
done
fi

if [[ -z “${rvm_path:-}” ]]
then
if (( UID == 0 ))
then
rvm_path="/usr/local/rvm"
else
rvm_path="${HOME}/.rvm"
fi
fi
export HOME rvm_path

Parse CLI arguments.

while (( $# > 0 ))
do
token="$1"
shift
case “$token” in

--trace)
  set -o xtrace
  export rvm_trace_flag=1
  ;;

--path)
  if [[ -n "${1:-}" ]]
  then
    rvm_path="$1"
    shift
  else
    fail "--path must be followed by a path."
  fi
  ;;

--branch) # Install RVM from a given branch
  if [[ -n "${1:-}" ]]
  then
    version="head"
    branch="$1"
    shift
  else
    fail "--branch must be followed by a branchname."
  fi
  ;;

--user-install)
  rvm_user_install_flag=1
  ;;

--version)
  case "$1" in
    +([[:digit:]]).+([[:digit:]]).+([[:digit:]]))
      version="$1"
      shift
      ;;
    latest|stable)
      version="latest"
      shift
      ;;
    head|master)
      version="head"
      shift
      branch="master"
      ;;
    *)
      fail "--version must be followed by a vaild version number x.y.z"
      ;;
  esac
  ;;

+([[:digit:]]).+([[:digit:]]).+([[:digit:]]))
  version="$token"
  ;;

help|usage)
  usage
  exit 0
  ;;

*)
usage
exit 1
;;

esac
done

true “${version:=head}”

if [[ “$rvm_path” != /* ]]
then
fail “The rvm install path must be fully qualified. Tried $rvm_path”
fi

rvm_src_path="$rvm_path/src"
rvm_archives_path="$rvm_path/archives"
rvm_releases_url=“https://rvm.beginrescueend.com/releases

for dir in “$rvm_src_path” “$rvm_archives_path”
do
if [[ ! -d “$dir” ]]
then
mkdir -p “$dir”
fi
done

Perform the actual installation, first we obtain the source using whichever

means was specified, if any. Defaults to head.

case “${version}” in
(head)
install_head
;;

(latest)
fetch_version
install_release
;;

(+([[:digit:]]).+([[:digit:]]).+([[:digit:]])) # x.y.z
install_release
;;
(*)
fail “Something went wrong, unrecognized version ‘$version’”
;;
esac

No matter which one we are doing we install the same way, using the RVM

installer script.

flags=()
if (( rvm_trace_flag == 1 ))
then
flags+=("–trace")
fi

if (( rvm_debug_flag == 1 ))
then
flags+=("–debug")
fi

chmod +x ./scripts/install

Now we run the RVM installer.

./scripts/install ${flags[*]} --path “$rvm_path”[/code]
a po tym wpisując:

gem install rails

wyskakuje:

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /Library/Ruby/Gems/1.8/gems/json-1.6.1/tests/test_json_string_matching.rb
z MACem i bashem do czynienia mam od kilku dni tak więc proszę o cierpliwość i wyrozumiałość

Zle wkleiles polecenie do konsoli… powinienes to zrobic dokladnie tak jak masz napisane na stronie rvma, czyli:

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

[quote=bkozal]Zle wkleiles polecenie do konsoli… powinienes to zrobic dokladnie tak jak masz napisane na stronie rvma, czyli:

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

[/quote]
no tak ale jeżeli wpisze tak jak mówisz to mam:

ERROR: Unable to clone the RVM repository, attempted both git:// and https://

wtedy próbuje:

bash < <(curl -s git://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

i to nie wyświetla nieczego, a po wpisaniu gem install rails:

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /Library/Ruby/Gems/1.8/gems/json-1.6.1/tests/test_json_string_matching.rb

A masz w ogole gita w systemie? :wink:

which git

Wyswietla jakas sciezke? Jezeli nie, to instalujesz homebrew: http://mxcl.github.com/homebrew/ i pozniej:

brew install git

I dopiero teraz rvm -> ruby -> railsy

…coraz bardziej utwierdzam się w przekonaniu, że jesteś trollem.
Zainstaluj rvma. i rubiego przez rvm. W sieci jest naprawdę sporo tutoriali krok po kroku, co trzeba zrobić, żeby go zainstalować - ba, nawet wklejenie Twojego błędu do wyszukiwarki daje rozwiązanie. Troll harder.
Edit:
widze, ze @bkozal mnie ubiegł :wink:

Nie mam doświadczenia z MACem, a tym bardziej z macem, jedynie podstawy jak pwd, ls, mkdir.
Cały czas szukam jakichś odpowiedzi na ten temat, tylko nadal nie dostrzegam jakich błędów mam szukać.

Zainstalowałem Gita i teraz mam which git /usr/local/bin/git
Teraz instaluje RVM

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

[code]Successfully checked out branch ‘’
Current branch master is up to date.
Successfully pulled (rebased) from origin

RVM: Shell scripts enabling management of multiple ruby environments.
RTFM: https://rvm.beginrescueend.com/
HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

Installing RVM to /Users/piotr/.rvm/
Correct permissions for base binaries in /Users/piotr/.rvm/bin…
Copying manpages into place.
Recording config files for rubies.

piotr,

If you have any questions, issues and/or ideas for improvement please
fork the project and issue a pull request.

If you wish to disable the project .rvmrc file functionality, set
rvm_project_rvmrc=0 in either /etc/rvmrc or ~/.rvmrc.

NOTE: To Multi-User installers, please do NOT forget to add your users to the ‘rvm’.
The installer no longer auto-adds root or users to the rvm group. Admins must do this.
Also, please note that group memberships are ONLY evaluated at login time.
This means that users must log out then back in before group membership takes effect!

Thank you for using RVM!

I sincerely hope that RVM helps to make your life easier and more enjoyable!!!

~Wayne

SYSTEM NOTES:

If you do not wish to enable reading of per-project .rvmrc files, simply set:
export rvm_project_rvmrc=0
within either your /etc/rvmrc or $HOME/.rvmrc file, then log out and back in.

You must read ‘rvm requirements’ for additional OS specific requirements for
various rubies, and native-extension gems. Expect failures until those are met!

You must now complete the install by loading RVM in new shells.

If you wish to use RVM in an interactive fashion in your shells then
Place the following line at the end of your shell’s loading files
(.bashrc or .bash_profile for bash and .zshrc for zsh),
after all PATH/variable settings:

[[ -s “/Users/piotr/.rvm/scripts/rvm” ]] && source “/Users/piotr/.rvm/scripts/rvm” # This loads RVM into a shell session.

You only need to add this line the first time you install RVM.

If you are choosing to source RVM into your environment to switch current
shell environments, be sure to close this shell and open a new one so that
the RVM functions load.

Installation of RVM to /Users/piotr/.rvm/ is complete.

Notes for Darwin ( Mac OS X )
For Snow Leopard: Xcode Version 3.2.1 (1613) or later, such as 3.2.6 or Xcode 4.1.
[ Please note that Xcode 3.x will not work on OS X Lion. The ‘cross-over’ is Xcode 4.1. ]

You should download the Xcode tools from developer.apple.com, since the Snow Leopard dvd install contained bugs.
You can find Xcode 4.1 for OS X Lion at:
https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.1_for_lion/xcode_4.1_for_lion.dmg

** Lion Users: Xcode Version 4.2.x for OS X Lion works only for ruby 1.9.3-p0 (or higher).
               It currently fails to build several other rubies and gems, as well as several Homebrew and
               Macports packages. Xcode Version 4.1 (4B110) works.

For MacRuby: Install LLVM first.
For JRuby:  Install the JDK. See http://developer.apple.com/java/download/  # Current Java version 1.6.0_26
For IronRuby: Install Mono >= 2.6

To use an RVM installed Ruby as default, instead of the system ruby:
  rvm install 1.8.7 # installs patch 352: closest supported version
  rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems
  rvm --default 1.8.7

./scripts/requirements: line 149: __rvm_detect_xcode_version_is: command not found[/code]
a instalacja railsów daje taki wynik:

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /Library/Ruby/Gems/1.8/gems/json-1.6.1/tests/test_json_string_matching.rb
czekam na jakąś podpowiedź i szukam dalej.

Wszystko masz napisane w tym co wkleiles.

Cześć wam, nadal męczy mnie ta instalacja rvma, doinstalowałem juz xcoda 4.1 ale informacja podczas instalacji rvma jest identyczna. co przegapiłem?

napewno nie jest identyczna, napewno coś przegapiłeś (hint: najpewniej dodanie do .bashrc magicznej linijki)
sprawdź czy pod konsolą masz dostępne polecenie rvm

Dodaj tą linijkę:

[[ -s "/Users/piotr/.rvm/scripts/rvm" ]] && source "/Users/piotr/.rvm/scripts/rvm"  # This loads RVM into a shell session.

do pliku /Users/piotr/.bash_profile (jak go nie ma, to go utwórz). Potem zamknij terminal i uruchom ponownie (lub otwórz nową kartę) i upewnij się, że rvm jest poprawnie zainstalowany przez wywołanie:

rvm notes

Jeśli wszystko będzie ok, to kolejno:

rvm install 1.9.2-head (<- ...to trochę potrwa) rvm use 1.9.2-head --default gem install rails

masz jakiś konkretny powód dla którego polecasz instalację 1.9.2 zamiast 1.9.3 ? :slight_smile:

Więc tak:
\najpierw pokazałem ukryte pliki:

defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder
utworzylem ten plik bez rozszerzenia i wpisałem

rvm notes

[code]SYSTEM NOTES:

If you do not wish to enable reading of per-project .rvmrc files, simply set:
export rvm_project_rvmrc=0
within either your /etc/rvmrc or $HOME/.rvmrc file, then log out and back in.

You must read ‘rvm requirements’ for additional OS specific requirements for
various rubies, and native-extension gems. Expect failures until those are met![/code]
i tutaj stoje z pytaniem instalować 192 czy 193, a jezeli 193 to czy wystarczy tylko podmienic cyfre :>?

zawsze możesz zainstalować obydwie wersje (rvm w zasadzie do tego służy, aby łatwo zmieniać sobie wersje) - ja używam 1.9.3 i sobie chwalę (z najbardziej zauważalnych rzeczy to testy wykonują się dużo szybciej) – problemem może być to, że część gemów może być niekompatybilna

hmm ale czyli do nauki zapewne 192 bedzie lepsza, bo tu raczej zaduzo czasu na testy nie bedzie potrzeba, a gemy raczej wszystkie by sie przydaly :stuck_out_tongue: zeby sobie problemow nie na rodbic z dogrywaniem czy jakims tam wydziwianiem . ok dzieki wiekie, jak stane w martwym punkcie to sie odezwe a teraz ide kombinowac


post sevosa wyzej zeby nie istalować xcode :slight_smile: wystarczy https://github.com/kennethreitz/osx-gcc-installer

Zainstalowałem railsa, stworzyłem aplikację i nie działa komenda rake db:create do stworzenia bazy danych, w pliku bin rubiego znalazłem plik rake ale on wyświetla to samo co po wpisaniu db:create

[code]rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

(See full trace by running task with --trace)
logout[/code]
czy ten plik rakefile.rb muszę jakoś sam utworzyć? wyczytałem że trzeba zainstalować starszą wersję rake, próbowalem to zrobić przez bundle install lecz wtedy wypisuje Could not locate Gemfile
proszę o jakąś podpowiedź :slight_smile: