åæã¨ãã¦Rubyçã¯ã©ããææ°ãã¼ã¸ã§ã³ãç¨ãããã¨ã¨ãã¾ãã
ã½ããã¦ã§ã¢ | ãã¼ã¸ã§ã³ |
rbenv | v1.5.1 |
Ruby | 3.3.5-1 |
Rails | 7.2.1.2 |
bundler | 2.5.22 |
æµã
1. PowerShellã¤ã³ã¹ãã¼ã«
C:\Users\ã¦ã¼ã¶å>winget search Microsoft.PowerShell 'msstore' ã½ã¼ã¹ã§ã¯ã使ç¨ããåã«æ¬¡ã®å¥ç´ã表示ããå¿ è¦ãããã¾ãã Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction ã½ã¼ã¹ãæ£å¸¸ã«æ©è½ããã«ã¯ãç¾å¨ã®ãã·ã³ã® 2 æåã®å°ççãªã¼ã¸ã§ã³ãããã¯ã¨ã³ã ãµã¼ãã¹ã«éä¿¡ããå¿ è¦ãããã¾ã (ä¾: "US")ã ãã¹ã¦ã®ã½ã¼ã¹å¥ç´æ¡ä»¶ã«åæãã¾ãã? [Y] ã¯ã [N] ããã: Y åå ID ãã¼ã¸ã§ã³ ã½ã¼ã¹ ------------------------------------------------------------------ PowerShell Microsoft.PowerShell 7.4.6.0 winget PowerShell Preview Microsoft.PowerShell.Preview 7.5.0.5 winget C:\Users\ã¦ã¼ã¶å>
2. rbenv for Windowsã¤ã³ã¹ãã¼ã«
ここ
ããFor common usersã«å¾ããrbenvã®ã¤ã³ã¹ãã¼ã«ãè¡ã
PS C:\Users\ã¦ã¼ã¶å> $env:RBENV_ROOT = "C:\rbenv" PS C:\Users\ã¦ã¼ã¶å> iwr -useb "https://github.com/RubyMetric/rbenv-for-windows/raw/main/tool/install.ps1" | iex ãã£ã¬ã¯ããª: C:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2024/10/26 11:24 rbenv Cloning into 'rbenv'... remote: Enumerating objects: 1658, done. remote: Counting objects: 100% (491/491), done. remote: Compressing objects: 100% (190/190), done. remote: Total 1658 (delta 294), reused 474 (delta 285), pack-reused 1167 (from 1) Receiving objects: 100% (1658/1658), 454.85 KiB | 6.23 MiB/s, done. Resolving deltas: 100% (1070/1070), done. Downloading pre-compiled binaries from GitHub... Finished Checking rbenv-binary-version.txt from GitHub... OK Update the local rbenv-binary-version.txt rbenv-installer: Installation complete! PS C:\Users\ã¦ã¼ã¶å>
3. ãããã¡ã¤ã«ã«è¿½è¨
PS C:\Users\ã¦ã¼ã¶å> Test-Path $profile False PS C:\Users\ã¦ã¼ã¶å>
Falseã®å ´å
PS C:\Users\ã¦ã¼ã¶å> New-Item -path $profile -type file -force ãã£ã¬ã¯ããª: C:\Users\ã¦ã¼ã¶å\Documents\WindowsPowerShell Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2024/10/26 16:00 0 Microsoft.PowerShell_profile.ps1 PS C:\Users\ã¦ã¼ã¶å>
Trueã®å ´å
PS C:\Users\ã¦ã¼ã¶å> Test-Path $profile True PS C:\Users\ã¦ã¼ã¶å>
PS C:\Users\ã¦ã¼ã¶å> notepad $profile ç·¨éå¾ã«ã¿ã¼ããã«åèµ·åãã¦åæ ===ãã®ã·ã¹ãã ã§ã¯ã¹ã¯ãªããã®å®è¡ãç¡å¹ã«ãªã£ã¦ããããããã¡ã¤ã«~~ã¨ãåºãå ´å=== PS C:\Users\ã¦ã¼ã¶å> Get-ExecutionPolicy Restricted PS C:\Users\ã¦ã¼ã¶å> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser PS C:\Users\ã¦ã¼ã¶å> Get-ExecutionPolicy RemoteSigned PS C:\Users\ã¦ã¼ã¶å> ===
â»æ¬¡åèµ·åæã«ä»¥ä¸ã®ããã«èªåDLãå§ã¾ã
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. æ°æ©è½ã¨æ¹åã®ããã«ææ°ã® PowerShell ãã¤ã³ã¹ãã¼ã«ãã¦ãã ãã!https://aka.ms/PSWindows Seems you have just installed rbenv, auto install MSYS2 for you MSYS2 is must-have if you want to install gems with C extensions Begin downloading ... => https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.3.5-1/rubyinstaller-devkit-3.3.5-1-x64.exe rubyinstaller-devkit-3.3.5-1-x64.exe (130.8 MB) [=============================================================] 100% Installing rubyinstaller-devkit-3.3.5-1-x64.exe(MSYS2) ... Moving the shared MSYS2 ... rbenv: Rehash all 13 executables in '3.3.5-1' rbenv: Remove version 3.3.5-1 registry info rbenv: The shared MSYS2 was installed successfully! rbenv: In addition, the newest version '3.3.5-1' was installed for you! rbenv: Change to global version '3.3.5-1' rbenv: Rehash all 13 executables in '3.3.5-1' ãã¼ã½ãã« ãããã¡ã¤ã«ã¨ã·ã¹ãã ãããã¡ã¤ã«ã®èªã¿è¾¼ã¿ã«ããã£ãæé㯠70544 ããªç§ã§ãã PS C:\Users\ã¦ã¼ã¶å>
4. Rubyã¨rbenvã®ãã¼ã¸ã§ã³ã確èª
PS C:\Users\ã¦ã¼ã¶å> ruby -v ruby 3.3.5-1 (set by C:\rbenv\global.txt) PS C:\Users\ã¦ã¼ã¶å>
rbenvããã確èªã§ãã
PS C:\Users\ã¦ã¼ã¶å> rbenv version 3.3.5-1 (set by C:\rbenv\global.txt) PS C:\Users\ã¦ã¼ã¶å>
- rbenv
PS C:\Users\ã¦ã¼ã¶å> rbenv -v rbenv v1.5.1 PS C:\Users\ã¦ã¼ã¶å>
5. SQLite3ã®ã¤ã³ã¹ãã¼ã«
SQLite Download Page
ããPrecompiled Binaries for Windowsã®sqlite-toolsãsqlite-dllã®zipãDLãã解åãã¦ä¸èº«ã®
sqlite3.dll
ã¨
sqlite3.exe
ãC:\rbenv\ãã¼ã¸ã§ã³\bin
以ä¸ã«ç§»å
6. Railsã¤ã³ã¹ãã¼ã«
PS C:\Users\ã¦ã¼ã¶å> gem install rails Fetching webrick-1.8.2.gem Fetching rackup-2.1.0.gem Fetching rack-3.1.8.gem Fetching thor-1.3.2.gem Fetching zeitwerk-2.7.1.gem Fetching concurrent-ruby-1.3.4.gem ... Done installing documentation for zeitwerk, thor, webrick, rack, rackup, concurrent-ruby, tzinfo, i18n, connection_pool, activesupport, useragent, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, rack-test, rack-session, erubi, builder, actionview, actionpack, railties, marcel, activemodel, activerecord, globalid, activejob, activestorage, actiontext, mini_mime, mail, actionmailer, actionmailbox, websocket-extensions, websocket-driver, nio4r, actioncable, rails after 38 seconds 39 gems installed A new release of RubyGems is available: 3.5.16 â 3.5.22! Run `gem update --system 3.5.22` to update your installation. PS C:\Users\ã¦ã¼ã¶å>
ãã¼ã¸ã§ã³ç¢ºèª
PS C:\Users\ã¦ã¼ã¶å> rails --version Rails 7.2.1.2
ããã¾ã§ã§ä¸éãã®ç°å¢æ§ç¯ã¯å®äºãã¦ãã
Windowsç¹æã®ã¨ã©ã¼ç
1. ã¤ã³ã¹ãã¼ã«ããã ãã ã¨rails g newçã使ããªã
ãããè´å½çâ¹ï¸
ãã®ã¾ã¾å®è¡ããã¨ã以ä¸ã®ãããªã¨ã©ã¼ãåºã
PS C:\Users\ã¦ã¼ã¶å\Desktop\work\csvtest\csvtest> rails new csvtest -G Based on the specified options, the following options will also be activated: --skip-decrypted-diffs [due to --skip-git] create create README.md create Rakefile create .ruby-version create config.ru create Gemfile create app create app/assets/config/manifest.js create app/assets/stylesheets/application.css ... Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: C:/rbenv/3.3.5-1/lib/ruby/gems/3.3.0/gems/psych-5.1.2/ext/psych C:/rbenv/3.3.5-1/bin/ruby.exe extconf.rb checking for pkg-config for yaml-0.1... not found checking for yaml.h... no yaml.h not found *** extconf.rb failed *** ... To see why this extension failed to compile, please check the mkmf.log which can be found here: C:/rbenv/3.3.5-1/lib/ruby/gems/3.3.0/extensions/x64-mingw-ucrt/3.3.0/psych-5.1.2/mkmf.log extconf failed, exit code 1 Gem files will remain installed in C:/rbenv/3.3.5-1/lib/ruby/gems/3.3.0/gems/psych-5.1.2 for inspection. Results logged to ... An error occurred while installing psych (5.1.2), and Bundler cannot continue. In Gemfile: debug was resolved to 1.9.2, which depends on irb was resolved to 1.14.1, which depends on rdoc was resolved to 6.7.0, which depends on psych run bundle lock --add-platform=x86_64-linux Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... Writing lockfile to C:/Users/ã¦ã¼ã¶å/Desktop/work/csvtest/csvtest/csvtest/Gemfile.lock run bundle binstubs bundler Could not find importmap-rails-2.0.3, turbo-rails-2.0.11, stimulus-rails-1.3.4, debug-1.9.2, rubocop-rails-omakase-1.0.0, web-console-4.2.1, irb-1.14.1, rdoc-6.7.0 in locally installed gems rails importmap:install Could not find importmap-rails-2.0.3, turbo-rails-2.0.11, stimulus-rails-1.3.4, debug-1.9.2, rubocop-rails-omakase-1.0.0, web-console-4.2.1, irb-1.14.1, rdoc-6.7.0 in locally installed gems Run `bundle install` to install missing gems. rails turbo:install stimulus:install Could not find importmap-rails-2.0.3, turbo-rails-2.0.11, stimulus-rails-1.3.4, debug-1.9.2, rubocop-rails-omakase-1.0.0, web-console-4.2.1, irb-1.14.1, rdoc-6.7.0 in locally installed gems Run `bundle install` to install missing gems. PS C:\Users\ã¦ã¼ã¶å\Desktop\work\csvtest\csvtest>
mkmf.logãè¦ãã¨æ¸ãã¦ããã®ã§ç¢ºèªããã¨ã以ä¸ã®ã¡ãã»ã¼ã¸ããã£ã
pkg_config: checking for pkg-config for yaml-0.1... -------------------- not found
ããã«é¢ãã¦ã¯ã¾ãã¾ã´ã£ããã®è§£æ±ºçããã£ã
bundle install の際 psychのインストールに失敗する 【Windows + Ruby3.2以降 + Rails7】 | RYOZEN - Creative Studio
ä¸è¨ãªã³ã¯ã«å¾ãã
C:\rbenv\ãã¼ã¸ã§ã³\lib
ã«
libyaml.a
ã¨
libyaml.dll.a
ãé
ç½®ããã°OK
å度rails new ããã°ãã¾ããã
2. bin/delayed_jobã³ãã³ãã使ããªã
PS C:\Users\ã¦ã¼ã¶å\Desktop\work\csvtest> ruby bin/delayed_job start C:/rbenv/3.3.5-1/lib/ruby/gems/3.3.0/gems/daemons-1.4.1/lib/daemons/daemonize.rb:10:in `fork': fork() function is unimplemented on this machine (NotImplementedError) from C:/rbenv/3.3.5-1/lib/ruby/gems/3.3.0/gems/daemons-1.4.1/lib/daemons/daemonize.rb:10:in `safefork'
代ããã«ã以ä¸ã³ãã³ãã使ã
rake jobs:work
3. Wheneverã使ããªã
Rake Taskä½æå¾ã«å®æå®è¡ãããã¤ãcrontabãWindowsã«ãªãã®ãæªã
代ããã«ãclockworkã使ã
clockwork .\config\clock.rb
ãããã¯ãRake Taskãä½æããããã§ã¿ã¹ã¯ã¹ã±ã¸ã¥ã¼ã©ã«ç»é²ãã